diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/AggregateCall.kt b/partiql-plan/src/main/java/org/partiql/plan/AggregateCall.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/AggregateCall.kt rename to partiql-plan/src/main/java/org/partiql/plan/AggregateCall.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Collation.kt b/partiql-plan/src/main/java/org/partiql/plan/Collation.java similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Collation.kt rename to partiql-plan/src/main/java/org/partiql/plan/Collation.java diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Exclusion.kt b/partiql-plan/src/main/java/org/partiql/plan/Exclusion.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Exclusion.kt rename to partiql-plan/src/main/java/org/partiql/plan/Exclusion.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/JoinType.kt b/partiql-plan/src/main/java/org/partiql/plan/JoinType.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/JoinType.kt rename to partiql-plan/src/main/java/org/partiql/plan/JoinType.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Operation.kt b/partiql-plan/src/main/java/org/partiql/plan/Operation.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Operation.kt rename to partiql-plan/src/main/java/org/partiql/plan/Operation.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Operator.kt b/partiql-plan/src/main/java/org/partiql/plan/Operator.java similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Operator.kt rename to partiql-plan/src/main/java/org/partiql/plan/Operator.java diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Plan.kt b/partiql-plan/src/main/java/org/partiql/plan/Plan.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Plan.kt rename to partiql-plan/src/main/java/org/partiql/plan/Plan.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Version.kt b/partiql-plan/src/main/java/org/partiql/plan/Version.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Version.kt rename to partiql-plan/src/main/java/org/partiql/plan/Version.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Visitor.kt b/partiql-plan/src/main/java/org/partiql/plan/Visitor.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Visitor.kt rename to partiql-plan/src/main/java/org/partiql/plan/Visitor.kt diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java b/partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java new file mode 100644 index 000000000..ee1e8340c --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java @@ -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(); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java new file mode 100644 index 000000000..b877d659c --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java @@ -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. + *
+ * TODO GROUP STRATEGY ISSUE + */ +public interface RelAggregate extends Rel { + + @NotNull + public Rel getInput(); + + @NotNull + public Collection getMeasures(); + + @NotNull + public Collection getGroups(); + + @NotNull + public Collection getChildren(); + + @Override + default public R accept(Visitor 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 args; + private final Boolean distinct; + + public Measure(Aggregation agg, Collection args, Boolean distinct) { + this.agg = agg; + this.args = args; + this.distinct = distinct; + } + + @NotNull + public Aggregation getAgg() { + return agg; + } + + @NotNull + public Collection getArgs() { + return args; + } + + @NotNull + public Boolean isDistinct() { + return distinct; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java new file mode 100644 index 000000000..59e4a3402 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitCorrelate(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java new file mode 100644 index 000000000..5f09989e9 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitDistinct(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java new file mode 100644 index 000000000..a1942d883 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitExcept(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java new file mode 100644 index 000000000..4190fb025 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java @@ -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 getExclusions(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitExclude(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java new file mode 100644 index 000000000..d35b1b43a --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java @@ -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. + *
+ *
+ *
    + *
  1. input (rel)
  2. + *
  3. predicate (rex)
  4. + *
+ */ +public interface RelFilter extends Rel { + + @NotNull + public Rel getInput(); + + @NotNull + public Rex getPredicate(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitFilter(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java new file mode 100644 index 000000000..47ed477f5 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitIntersect(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java new file mode 100644 index 000000000..03bd10e53 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java @@ -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 AS AT `. + */ +public interface RelIterate extends Rel { + + @NotNull + public Rex getRex(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitIterate(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java new file mode 100644 index 000000000..03b0d60b4 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitJoin(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java new file mode 100644 index 000000000..291344d46 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitLimit(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java new file mode 100644 index 000000000..8c8f682f9 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java @@ -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 accept(Visitor visitor, C ctx) { + return visitor.visitOffset(this, ctx); + } +} + diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java new file mode 100644 index 000000000..4480ffb06 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java @@ -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 getProjections(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitProject(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java new file mode 100644 index 000000000..c466e6a54 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java @@ -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 AS `. + */ +public interface RelScan extends Rel { + + @NotNull + public Rex getRex(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitScan(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java new file mode 100644 index 000000000..68cb41cdd --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java @@ -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 getCollations(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitSort(this, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java new file mode 100644 index 000000000..7952da872 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java @@ -0,0 +1,23 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.types.Field; + +/** + * Analogous to a ROW type, consider rank/cardinality or other hint mechanisms. + */ +public interface RelType { + + public int getFieldSize(); + + @NotNull + public Field[] getFields(); + + @NotNull + public Field getField(String name); + + /** + * @return true if the rel produces an ordered stream of rows. + */ + public boolean isOrdered(); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnion.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnion.java new file mode 100644 index 000000000..bf22d6da0 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnion.java @@ -0,0 +1,24 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Visitor; + +/** + * Logical `UNION [ALL|DISTINCT]` operator for set (or multiset) union. + */ +public interface RelUnion extends Rel { + + public boolean isAll(); + + @NotNull + public Rel getLeft(); + + @NotNull + public Rel getRight(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitUnion(this, ctx); + } +} + diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnpivot.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnpivot.java new file mode 100644 index 000000000..bc91ad415 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnpivot.java @@ -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 `UNPIVOT` operator. + */ +public interface RelUnpivot extends Rel { + + @NotNull + public Rex getRex(); + + @Override + default public R accept(Visitor visitor, C ctx) { + return visitor.visitUnpivot(this, ctx); + } +} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/Rex.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/Rex.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/Rex.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexArray.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexArray.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexBag.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexBag.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCall.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCall.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCallDynamic.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCallDynamic.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCase.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCase.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCast.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCast.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCoalesce.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCoalesce.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexError.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexError.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexError.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexLit.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexLit.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexNullIf.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexNullIf.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathIndex.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathIndex.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathKey.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathKey.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathSymbol.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathSymbol.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPivot.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPivot.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSelect.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSelect.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSpread.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSpread.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexStruct.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexStruct.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubquery.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubquery.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryComp.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryComp.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryIn.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryIn.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryTest.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryTest.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexTable.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexTable.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexType.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexType.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexType.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexType.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexVar.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.kt similarity index 100% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexVar.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.kt diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelDistinct.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt similarity index 66% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelDistinct.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt index 77ae8a3b5..f4274ca9c 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelDistinct.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt @@ -1,24 +1,5 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor - -/** - * Logical `DISTINCT` operator. - */ -public interface RelDistinct : Rel { - - public fun getInput(): Rel - - override fun getChildren(): Collection = listOf(getInput()) - - override fun getType(): RelType = getInput().getType() - - override fun isOrdered(): Boolean = getInput().isOrdered() - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitDistinct(this, ctx) -} - /** * Default [RelDistinct] implementation. */ @@ -51,4 +32,4 @@ internal class RelDistinctImpl(input: Rel) : RelDistinct { override fun hashCode(): Int { return _input.hashCode() } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExcept.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt similarity index 72% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExcept.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt index a74cb8a33..42ca73359 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExcept.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt @@ -1,26 +1,5 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor - -/** - * Logical `EXCEPT [ALL|DISTINCT]` operator for set (or multiset) difference. - */ -public interface RelExcept : Rel { - - public fun isAll(): Boolean - - public fun getLeft(): Rel - - public fun getRight(): Rel - - override fun getChildren(): Collection = listOf(getLeft(), getRight()) - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitExcept(this, ctx) -} - /** * Default [RelExcept] implementation. */ @@ -67,4 +46,4 @@ internal class RelExceptImpl(left: Rel, right: Rel, isAll: Boolean) : result = 31 * result + _right.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExclude.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExcludeImpl.kt similarity index 72% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExclude.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExcludeImpl.kt index 3e3522b5e..82af2847a 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExclude.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExcludeImpl.kt @@ -1,24 +1,6 @@ package org.partiql.plan.rel import org.partiql.plan.Exclusion -import org.partiql.plan.Visitor - -/** - * Logical `EXCLUDE` operation. - */ -public interface RelExclude : Rel { - - public fun getInput(): Rel - - public fun getExclusions(): List - - override fun getChildren(): Collection = listOf(getInput()) - - override fun isOrdered(): Boolean = getInput().isOrdered() - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitExclude(this, ctx) -} /** * Default [RelExclude] implementation. @@ -56,4 +38,4 @@ internal class RelExcludeImpl(input: Rel, exclusions: List) : RelExcl result = 31 * result + _exclusions.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelFilter.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt similarity index 68% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelFilter.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt index e76b86981..3d603dc55 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelFilter.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt @@ -1,30 +1,7 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * Logical filter operation for the WHERE and HAVING clauses. - * - * arg 0 – rel input - * arg 1 - rex predicate - */ -public interface RelFilter : Rel { - - public fun getInput(): Rel - - public fun getPredicate(): Rex - - override fun getChildren(): Collection = listOf(getInput()) - - override fun getType(): RelType = getInput().getType() - - override fun isOrdered(): Boolean = getInput().isOrdered() - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitFilter(this, ctx) -} - /** * Default [RelFilter] implementation. */ @@ -65,4 +42,4 @@ internal class RelFilterImpl(input: Rel, predicate: Rex) : RelFilter { result = 31 * result + _predicate.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIntersect.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt similarity index 71% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIntersect.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt index 4062ff6c4..9877701d9 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIntersect.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt @@ -1,26 +1,5 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor - -/** - * Logical `INTERSECT [ALL|DISTINCT]` operator for set (or multiset) intersection. - */ -public interface RelIntersect : Rel { - - public fun isAll(): Boolean - - public fun getLeft(): Rel - - public fun getRight(): Rel - - override fun getChildren(): Collection = listOf(getLeft(), getRight()) - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitIntersect(this, ctx) -} - /** * Default [RelIntersect] implementation. */ @@ -67,4 +46,4 @@ internal class RelIntersectImpl(left: Rel, right: Rel, isAll: Boolean) : result = 31 * result + _right.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIterate.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIterateImpl.kt similarity index 60% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIterate.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIterateImpl.kt index 15b6cc9a5..f5c81ce0a 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIterate.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIterateImpl.kt @@ -1,23 +1,7 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * Logical scan corresponding to the clause `FROM AS AT `. - */ -public interface RelIterate : Rel { - - public fun getInput(): Rex - - override fun getChildren(): Collection = emptyList() - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitIterate(this, ctx) -} - /** * Default [RelIterate] implementation. */ @@ -41,4 +25,4 @@ internal class RelIterateImpl(input: Rex) : RelIterate { override fun hashCode(): Int { return _input.hashCode() } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelJoin.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt similarity index 71% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelJoin.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt index 6846b0817..9262aec3f 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelJoin.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt @@ -1,35 +1,8 @@ package org.partiql.plan.rel import org.partiql.plan.JoinType -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * TODO DOCUMENTATION - */ -public interface RelJoin : Rel { - - public fun getLeft(): Rel - - // TODO REMOVE ME TEMPORARY – https://github.com/partiql/partiql-lang-kotlin/issues/1575 - public fun getLeftSchema(): RelType? - - public fun getRight(): Rel - - // TODO REMOVE ME TEMPORARY – https://github.com/partiql/partiql-lang-kotlin/issues/1575 - public fun getRightSchema(): RelType? - - public fun getCondition(): Rex? - - public fun getJoinType(): JoinType - - override fun getChildren(): Collection = listOf(getLeft(), getRight()) - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitJoin(this, ctx) -} - /** * Default [RelJoin] implementation. */ @@ -95,4 +68,4 @@ internal class RelJoinImpl( result = 31 * result + _joinType.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelLimit.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt similarity index 68% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelLimit.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt index ada7af34b..411e8b889 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelLimit.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt @@ -1,26 +1,7 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * Logical `LIMIT` operator. - */ -public interface RelLimit : Rel { - - public fun getInput(): Rel - - public fun getLimit(): Rex - - override fun getChildren(): Collection = listOf(getInput()) - - override fun getType(): RelType = getInput().getType() - - override fun isOrdered(): Boolean = getInput().isOrdered() - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitLimit(this, ctx) -} - /** * Default [RelLimit] implementation. */ @@ -54,4 +35,4 @@ internal class RelLimitImpl(input: Rel, limit: Rex) : RelLimit { result = 31 * result + _limit.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelOffset.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt similarity index 68% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelOffset.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt index 5ab13454f..f6feb64d8 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelOffset.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt @@ -1,26 +1,7 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * Logical `OFFSET` operator. - */ -public interface RelOffset : Rel { - - public fun getInput(): Rel - - public fun getOffset(): Rex - - override fun getChildren(): Collection = listOf(getInput()) - - override fun getType(): RelType = getInput().getType() - - override fun isOrdered(): Boolean = getInput().isOrdered() - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitOffset(this, ctx) -} - /** * Default [RelOffset] implementation. */ @@ -54,4 +35,4 @@ internal class RelOffsetImpl(input: Rel, offset: Rex) : RelOffset { result = 31 * result + _offset.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelProject.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt similarity index 70% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelProject.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt index 3e50f26da..3d9173950 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelProject.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt @@ -1,24 +1,7 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * Logical `PROJECTION` operator - */ -public interface RelProject : Rel { - - public fun getInput(): Rel - - public fun getProjections(): List - - override fun getChildren(): Collection = listOf(getInput()) - - override fun isOrdered(): Boolean = getInput().isOrdered() - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitProject(this, ctx) -} - /** * Default [RelProject] implementation. */ @@ -52,4 +35,4 @@ public class RelProjectImpl(input: Rel, projections: List) : RelProject { result = 31 * result + _projections.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelScan.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt similarity index 61% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelScan.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt index 6c98ce1db..9485afb62 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelScan.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt @@ -1,22 +1,7 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor import org.partiql.plan.rex.Rex -/** - * Logical scan corresponding to the clause `FROM AS `. - */ -public interface RelScan : Rel { - - public fun getInput(): Rex - - override fun getChildren(): Collection = emptyList() - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitScan(this, ctx) -} - /** * Default [RelScan] implementation. */ @@ -40,4 +25,4 @@ internal class RelScanImpl(input: Rex) : RelScan { override fun hashCode(): Int { return _input.hashCode() } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelSort.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt similarity index 71% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelSort.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt index 31ee8c8df..bd3d1ae90 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelSort.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt @@ -1,25 +1,6 @@ package org.partiql.plan.rel import org.partiql.plan.Collation -import org.partiql.plan.Visitor - -/** - * Logical sort operator. - */ -public interface RelSort : Rel { - - public fun getInput(): Rel - - public fun getCollations(): List - - override fun getChildren(): Collection = listOf(getInput()) - - override fun getType(): RelType = getInput().getType() - - override fun isOrdered(): Boolean = true - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSort(this, ctx) -} /** * Default [RelSort] implementation. @@ -59,4 +40,4 @@ internal class RelSortImpl(input: Rel, collations: List) : RelSort { result = 31 * result + _collations.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnion.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt similarity index 72% rename from partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnion.kt rename to partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt index ecfb2dcfc..bb80676cb 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnion.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt @@ -1,25 +1,5 @@ package org.partiql.plan.rel -import org.partiql.plan.Visitor - -/** - * Logical `UNION [ALL|DISTINCT]` operator for set (or multiset) union. - */ -public interface RelUnion : Rel { - - public fun isAll(): Boolean - - public fun getLeft(): Rel - - public fun getRight(): Rel - - override fun getChildren(): Collection = listOf(getLeft(), getRight()) - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitUnion(this, ctx) -} - /** * Default [RelUnion] implementation. */ @@ -66,4 +46,4 @@ internal class RelUnionImpl(left: Rel, right: Rel, isAll: Boolean) : result = 31 * result + _right.hashCode() return result } -} +} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnpivotImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnpivotImpl.kt new file mode 100644 index 000000000..112cd10a9 --- /dev/null +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnpivotImpl.kt @@ -0,0 +1,2 @@ +package org.partiql.plan.rel + diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/Rel.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/Rel.kt deleted file mode 100644 index 55d3d9af8..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/Rel.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.Operator - -/** - * A [Rel] is an [Operator] that produces a collection of tuples. - */ -public interface Rel : Operator { - - public fun getType(): RelType - - public fun isOrdered(): Boolean -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelAggregate.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelAggregate.kt deleted file mode 100644 index 4a0c0e550..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelAggregate.kt +++ /dev/null @@ -1,75 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.AggregateCall -import org.partiql.plan.Visitor -import org.partiql.plan.rex.Rex - -/** - * TODO GROUP STRATEGY - * TODO GROUP BY - */ -public interface RelAggregate : Rel { - - public fun getInput(): Rel - - public fun getCalls(): List - - public fun getGroups(): List - - override fun getChildren(): Collection = listOf(getInput()) - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitAggregate(this, ctx) -} - -/** - * Default [RelAggregate] implementation. - */ -internal class RelAggregateImpl( - input: Rel, - calls: List, - groups: List, -) : - RelAggregate { - - // DO NOT USE FINAL - private var _input = input - private var _calls = calls - private var _groups = groups - - private var _children: List? = null - - override fun getInput(): Rel = _input - - override fun getCalls(): List = _calls - - override fun getGroups(): List = _groups - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_input) - } - return _children!! - } - - override fun getType(): RelType { - TODO("Not yet implemented") - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelAggregate) return false - if (_input != other.getInput()) return false - if (_calls != other.getCalls()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _calls.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelCorrelate.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelCorrelate.kt deleted file mode 100644 index b8f51b2f4..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelCorrelate.kt +++ /dev/null @@ -1,72 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.JoinType -import org.partiql.plan.Visitor - -/** - * Logical operator for nested-loop joins (correlated subqueries // lateral joins). - */ -public interface RelCorrelate : Rel { - - public fun getLeft(): Rel - - public fun getRight(): Rel - - public fun getJoinType(): JoinType - - override fun getChildren(): Collection = listOf(getLeft(), getRight()) - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = - visitor.visitCorrelate(this, ctx) -} - -/** - * Default [RelCorrelate] implementation. - */ -internal class RelCorrelateImpl(left: Rel, right: Rel, joinType: JoinType) : RelCorrelate { - - // DO NOT USE FINAL - private var _left = left - private var _right = right - private var _joinType = joinType - - private var _children: List? = null - - override fun getLeft(): Rel = _left - - override fun getRight(): Rel = _right - - override fun getJoinType(): JoinType = _joinType - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_left, _right) - } - return _children!! - } - - override fun getType(): RelType { - TODO("Not yet implemented") - } - - override fun isOrdered(): Boolean = false - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelCorrelate) return false - if (_left != other.getLeft()) return false - if (_right != other.getRight()) return false - if (_joinType != other.getJoinType()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _left.hashCode() - result = 31 * result + _right.hashCode() - result = 31 * result + _joinType.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelType.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelType.kt deleted file mode 100644 index cd2a3da43..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelType.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.types.Field - -/** - * Analogous to a ROW type. - * - * TODO does not need to be an interface. - */ -public interface RelType { - - public fun getSize(): Int = getFields().size - - public fun getFields(): List - - public fun getField(name: String): Field -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnpivot.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnpivot.kt deleted file mode 100644 index d64278c9c..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnpivot.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.Visitor -import org.partiql.plan.rex.Rex - -/** - * TODO DOCUMENTATION - */ -public interface RelUnpivot : Rel { - - public fun getInput(): Rex - - override fun getChildren(): Collection = emptyList() - - override fun isOrdered(): Boolean = false - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitUnpivot(this, ctx) -} - -/** - * Default [RelUnpivot] implementation. - */ -internal class RelUnpivotImpl(input: Rex) : RelUnpivot { - - // DO NOT USE FINAL - private var _input: Rex = input - - override fun getInput(): Rex = _input - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || other !is RelUnpivot) return false - return _input == other.getInput() - } - - override fun getType(): RelType { - TODO("Not yet implemented") - } - - override fun hashCode(): Int { - return _input.hashCode() - } -}