Skip to content

Commit

Permalink
Swith rel interfaces to java
Browse files Browse the repository at this point in the history
  • Loading branch information
RCHowell committed Nov 27, 2024
1 parent 6a4b3e2 commit 3d6ddac
Show file tree
Hide file tree
Showing 71 changed files with 466 additions and 487 deletions.
16 changes: 16 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Operator;

/**
* A Rel is an {@link Operator that produces a collection of tuples.
*/
public interface Rel extends Operator {

/**
* @return RelType.
*/
@NotNull
public RelType getType();
}
65 changes: 65 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Operator;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;
import org.partiql.spi.function.Aggregation;

import java.util.Collection;

/**
* Interface for an aggregation operator.
* <br>
* TODO GROUP STRATEGY <a href="https://github.com/partiql/partiql-lang-kotlin/issues/1664">ISSUE</a>
*/
public interface RelAggregate extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Collection<Measure> getMeasures();

@NotNull
public Collection<Rex> getGroups();

@NotNull
public Collection<Operator> getChildren();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitAggregate(this, ctx);
}

/**
* An aggregation function along with its arguments and any additional filters (e.g. DISTINCT).
*/
public class Measure {

private final Aggregation agg;
private final Collection<Rex> args;
private final Boolean distinct;

public Measure(Aggregation agg, Collection<Rex> args, Boolean distinct) {
this.agg = agg;
this.args = args;
this.distinct = distinct;
}

@NotNull
public Aggregation getAgg() {
return agg;
}

@NotNull
public Collection<Rex> getArgs() {
return args;
}

@NotNull
public Boolean isDistinct() {
return distinct;
}
}
}
24 changes: 24 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;

/**
* Logical operator for nested-loop joins (correlated subqueries // lateral joins).
*/
public interface RelCorrelate extends Rel {

@NotNull
public Rel getLeft();

@NotNull
public Rel getRight();

@NotNull
public Rel getJoinType();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitCorrelate(this, ctx);
}
}
18 changes: 18 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;

/**
* Logical `DISTINCT` operator.
*/
public interface RelDistinct extends Rel {

@NotNull
public Rel getInput();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitDistinct(this, ctx);
}
}
26 changes: 26 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;

/**
* Logical `EXCEPT [ALL|DISTINCT]` operator for set (or multiset) difference.
*/
public interface RelExcept extends Rel {

/**
* @return true if the `ALL` keyword was used, false otherwise.
*/
public boolean isAll();

@NotNull
public Rel getLeft();

@NotNull
public Rel getRight();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitExcept(this, ctx);
}
}
24 changes: 24 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Exclusion;
import org.partiql.plan.Visitor;

import java.util.Collection;

/**
* Logical `EXCLUDE` operator.
*/
public interface RelExclude extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Collection<Exclusion> getExclusions();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitExclude(this, ctx);
}
}
28 changes: 28 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

/**
* Logical filter operation for the WHERE and HAVING clauses.
* <br>
* <br>
* <ol>
* <li>input (rel)</li>
* <li>predicate (rex)</li>
* </ol>
*/
public interface RelFilter extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Rex getPredicate();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitFilter(this, ctx);
}
}
23 changes: 23 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;

/**
* Logical `INTERSECT [ALL|DISTINCT]` operator for set (or multiset) intersection.
*/
public interface RelIntersect extends Rel {

public boolean isAll();

@NotNull
public Rel getLeft();

@NotNull
public Rel getRight();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitIntersect(this, ctx);
}
}
19 changes: 19 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

/**
* Logical scan corresponding to the clause `FROM <expression> AS <v> AT <i>`.
*/
public interface RelIterate extends Rel {

@NotNull
public Rex getRex();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitIterate(this, ctx);
}
}
30 changes: 30 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.plan.JoinType;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

/**
* Logical join operator.
*/
public interface RelJoin extends Rel {

@NotNull
public Rel getLeft();

@NotNull
public Rel getRight();

@NotNull
public JoinType getJoinType();

@Nullable
public Rex getCondition();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitJoin(this, ctx);
}
}
22 changes: 22 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

/**
* Logical `LIMIT` operator.
*/
public interface RelLimit extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Rex getLimit();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitLimit(this, ctx);
}
}
23 changes: 23 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

/**
* Logical `OFFSET` operator.
*/
public interface RelOffset extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Rex getOffset();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitOffset(this, ctx);
}
}

24 changes: 24 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

import java.util.Collection;

/**
* Logical `PROJECTION` operator
*/
public interface RelProject extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Collection<Rex> getProjections();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitProject(this, ctx);
}
}
19 changes: 19 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Visitor;
import org.partiql.plan.rex.Rex;

/**
* Logical scan corresponding to the clause `FROM <expression> AS <v>`.
*/
public interface RelScan extends Rel {

@NotNull
public Rex getRex();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitScan(this, ctx);
}
}
24 changes: 24 additions & 0 deletions partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.partiql.plan.rel;

import org.jetbrains.annotations.NotNull;
import org.partiql.plan.Collation;
import org.partiql.plan.Visitor;

import java.util.Collection;

/**
* Logical sort operator.
*/
public interface RelSort extends Rel {

@NotNull
public Rel getInput();

@NotNull
public Collection<Collation> getCollations();

@Override
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) {
return visitor.visitSort(this, ctx);
}
}
Loading

0 comments on commit 3d6ddac

Please sign in to comment.