-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
466 additions
and
487 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
65
partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
30
partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.