From 7886f193031d86462c23055c5d23340368849b62 Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Wed, 27 Nov 2024 15:15:45 -0500 Subject: [PATCH] Updates rels to java abc --- .../internal/compiler/StandardCompiler.kt | 4 +- .../main/java/org/partiql/plan/Collation.java | 105 +++++++++++++++--- .../main/java/org/partiql/plan/Operator.java | 46 ++++++-- .../main/java/org/partiql/plan/rel/Rel.java | 2 +- .../org/partiql/plan/rel/RelAggregate.java | 43 +++++-- .../java/org/partiql/plan/rel/RelBase.java | 28 +++++ .../org/partiql/plan/rel/RelCorrelate.java | 45 +++++++- .../org/partiql/plan/rel/RelDistinct.java | 36 +++++- .../java/org/partiql/plan/rel/RelExcept.java | 46 ++++++-- .../java/org/partiql/plan/rel/RelExclude.java | 40 ++++++- .../java/org/partiql/plan/rel/RelFilter.java | 49 ++++++-- .../org/partiql/plan/rel/RelIntersect.java | 47 +++++++- .../java/org/partiql/plan/rel/RelIterate.java | 34 +++++- .../java/org/partiql/plan/rel/RelJoin.java | 46 ++++++-- .../java/org/partiql/plan/rel/RelLimit.java | 42 ++++++- .../java/org/partiql/plan/rel/RelOffset.java | 42 ++++++- .../java/org/partiql/plan/rel/RelProject.java | 40 ++++++- .../java/org/partiql/plan/rel/RelScan.java | 36 +++++- .../java/org/partiql/plan/rel/RelSort.java | 34 +++++- .../java/org/partiql/plan/rel/RelType.java | 8 +- .../java/org/partiql/plan/rel/RelUnion.java | 48 ++++++-- .../java/org/partiql/plan/rel/RelUnpivot.java | 36 +++++- .../main/java/org/partiql/plan/rex/Rex.java | 13 +++ .../src/main/java/org/partiql/plan/rex/Rex.kt | 11 -- .../plan/rex/{RexArray.kt => RexArray.java} | 7 +- .../plan/rex/{RexBag.kt => RexBag.java} | 7 +- .../plan/rex/{RexCall.kt => RexCall.java} | 7 +- ...{RexCallDynamic.kt => RexCallDynamic.java} | 7 +- .../plan/rex/{RexCase.kt => RexCase.java} | 7 +- .../plan/rex/{RexCast.kt => RexCast.java} | 7 +- .../rex/{RexCoalesce.kt => RexCoalesce.java} | 7 +- .../plan/rex/{RexError.kt => RexError.java} | 5 +- .../plan/rex/{RexLit.kt => RexLit.java} | 5 +- .../plan/rex/{RexNullIf.kt => RexNullIf.java} | 7 +- .../{RexPathIndex.kt => RexPathIndex.java} | 5 +- .../rex/{RexPathKey.kt => RexPathKey.java} | 5 +- .../{RexPathSymbol.kt => RexPathSymbol.java} | 5 +- .../plan/rex/{RexPivot.kt => RexPivot.java} | 7 +- .../plan/rex/{RexSelect.kt => RexSelect.java} | 7 +- .../plan/rex/{RexSpread.kt => RexSpread.java} | 5 +- .../plan/rex/{RexStruct.kt => RexStruct.java} | 7 +- .../rex/{RexSubquery.kt => RexSubquery.java} | 5 +- ...exSubqueryComp.kt => RexSubqueryComp.java} | 5 +- .../{RexSubqueryIn.kt => RexSubqueryIn.java} | 5 +- ...exSubqueryTest.kt => RexSubqueryTest.java} | 5 +- .../plan/rex/{RexTable.kt => RexTable.java} | 5 +- .../plan/rex/{RexType.kt => RexType.java} | 0 .../plan/rex/{RexVar.kt => RexVar.java} | 5 +- .../org/partiql/plan/builder/PlanFactory.kt | 32 +++--- .../org/partiql/plan/impl/RelDistinctImpl.kt | 35 ------ .../org/partiql/plan/impl/RelExceptImpl.kt | 49 -------- .../org/partiql/plan/impl/RelExcludeImpl.kt | 41 ------- .../org/partiql/plan/impl/RelFilterImpl.kt | 45 -------- .../org/partiql/plan/impl/RelIntersectImpl.kt | 49 -------- .../org/partiql/plan/impl/RelIterateImpl.kt | 28 ----- .../org/partiql/plan/impl/RelJoinImpl.kt | 71 ------------ .../org/partiql/plan/impl/RelLimitImpl.kt | 38 ------- .../org/partiql/plan/impl/RelOffsetImpl.kt | 38 ------- .../org/partiql/plan/impl/RelProjectImpl.kt | 38 ------- .../org/partiql/plan/impl/RelScanImpl.kt | 28 ----- .../org/partiql/plan/impl/RelSortImpl.kt | 43 ------- .../org/partiql/plan/impl/RelUnionImpl.kt | 49 -------- .../org/partiql/plan/impl/RelUnpivotImpl.kt | 2 - 63 files changed, 838 insertions(+), 766 deletions(-) create mode 100644 partiql-plan/src/main/java/org/partiql/plan/rel/RelBase.java create mode 100644 partiql-plan/src/main/java/org/partiql/plan/rex/Rex.java delete mode 100644 partiql-plan/src/main/java/org/partiql/plan/rex/Rex.kt rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexArray.kt => RexArray.java} (76%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexBag.kt => RexBag.java} (77%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexCall.kt => RexCall.java} (80%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexCallDynamic.kt => RexCallDynamic.java} (82%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexCase.kt => RexCase.java} (92%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexCast.kt => RexCast.java} (85%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexCoalesce.kt => RexCoalesce.java} (76%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexError.kt => RexError.java} (68%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexLit.kt => RexLit.java} (81%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexNullIf.kt => RexNullIf.java} (79%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexPathIndex.kt => RexPathIndex.java} (77%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexPathKey.kt => RexPathKey.java} (77%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexPathSymbol.kt => RexPathSymbol.java} (79%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexPivot.kt => RexPivot.java} (87%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexSelect.kt => RexSelect.java} (84%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexSpread.kt => RexSpread.java} (84%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexStruct.kt => RexStruct.java} (87%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexSubquery.kt => RexSubquery.java} (89%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexSubqueryComp.kt => RexSubqueryComp.java} (91%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexSubqueryIn.kt => RexSubqueryIn.java} (80%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexSubqueryTest.kt => RexSubqueryTest.java} (87%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexTable.kt => RexTable.java} (84%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexType.kt => RexType.java} (100%) rename partiql-plan/src/main/java/org/partiql/plan/rex/{RexVar.kt => RexVar.java} (87%) delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExcludeImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIterateImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnpivotImpl.kt diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/compiler/StandardCompiler.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/compiler/StandardCompiler.kt index c12e3a3f7..d0ed3ed15 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/compiler/StandardCompiler.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/compiler/StandardCompiler.kt @@ -195,7 +195,7 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { override fun visitAggregate(rel: RelAggregate, ctx: Unit): ExprRelation { val input = compile(rel.getInput(), ctx) - val aggs = rel.getCalls().map { call -> + val aggs = rel.getMeasures().map { call -> val agg = call.getAgg() val args = call.getArgs().map { compile(it, ctx).catch() } val distinct = call.isDistinct() @@ -241,7 +241,7 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { } override fun visitIterate(rel: RelIterate, ctx: Unit): ExprRelation { - val input = compile(rel.getInput(), ctx) + val input = compile(rel.getRex(), ctx) return when (mode) { Mode.PERMISSIVE -> RelOpIteratePermissive(input) Mode.STRICT -> RelOpIterate(input) diff --git a/partiql-plan/src/main/java/org/partiql/plan/Collation.java b/partiql-plan/src/main/java/org/partiql/plan/Collation.java index bf052768f..ee68494b1 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/Collation.java +++ b/partiql-plan/src/main/java/org/partiql/plan/Collation.java @@ -1,30 +1,105 @@ -package org.partiql.plan +package org.partiql.plan; -import org.partiql.plan.rex.Rex +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.rex.Rex; +import org.partiql.spi.Enum; /** - * TODO DOCUMENTATION + * Represents a collation, which is a resolved sort specification. */ public interface Collation { /** - * TODO REPLACE WITH COLUMN INDEX + * API WARNING – THIS WILL BE REPLACED WITH AN `int` IN 1.0. + *
+ * TODO replace with an `int` in 1.0 + * TODO ... + * + * @return the column to sort by */ - public fun getRex(): Rex + public Rex getColumn(); - public fun getOrder(): Order + /** + * @return ASC, DESC, or OTHER + */ + public Order getOrder(); + + /** + * @return NULL ordering + */ + public Nulls getNulls(); + + /** + * Collation value ordering. + */ + public final class Order extends Enum { + + private Order(int code) { + super(code); + } - public fun getNulls(): Nulls + public static final int UNKNOWN = 0; + public static final int ASC = 1; + public static final int DESC = 2; - public enum class Order { - ASC, - DESC, - OTHER, + @NotNull + public static Order ASC() { + return new Order(ASC); + } + + @NotNull + public static Order DESC() { + return new Order(DESC); + } + + @Override + public String toString() { + int code = code(); + switch (code) { + case ASC: + return "ASC"; + case DESC: + return "DESC"; + default: + return String.valueOf(code); + } + } } - public enum class Nulls { - FIRST, - LAST, - OTHER, + /** + * Collation null ordering. + */ + public final class Nulls extends Enum { + + private Nulls(int code) { + super(code); + } + + public static final int UNKNOWN = 0; + public static final int FIRST = 1; + public static final int LAST = 2; + + @NotNull + public static Order FIRST() { + return new Order(FIRST); + } + + @NotNull + public static Order LAST() { + return new Order(LAST); + } + + @Override + public String toString() { + int code = code(); + switch (code) { + case FIRST: + return "FIRST"; + case LAST: + return "LAST"; + default: + return String.valueOf(code); + } + } } } diff --git a/partiql-plan/src/main/java/org/partiql/plan/Operator.java b/partiql-plan/src/main/java/org/partiql/plan/Operator.java index 083e27a2c..0afafe439 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/Operator.java +++ b/partiql-plan/src/main/java/org/partiql/plan/Operator.java @@ -1,25 +1,49 @@ -package org.partiql.plan +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; /** - * Operator is the interface for a logical plan operator. + * The interface for all logical plan operators. */ public interface Operator { - public fun accept(visitor: Visitor, ctx: C): R + /** + * Tag getter. + */ + public int getTag(); /** - * Get i-th child (input) operator. + * Tag setter. * - * @param index + * @param tag new tag value. */ - public fun getChild(index: Int) { - throw UnsupportedOperationException("getChild") - } + public void setTag(int tag); /** - * Get all child (input) operators. + * Visitor accept. * - * @return + * @param visitor visitor implementation. + * @param ctx visitor scoped args. + * @param Visitor return type. + * @param Visitor context type (scoped args). + * @return R + */ + public abstract R accept(Visitor visitor, C ctx); + + /** + * Get i-th child (input) operator. + * + * @param index child index + * @return child operator + */ + @NotNull + public abstract Operator getChild(int index); + + /** + * @return all child (input) operators. */ - public fun getChildren(): Collection + @NotNull + public abstract List getChildren(); } 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 index ee1e8340c..f4c152f0d 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java @@ -12,5 +12,5 @@ public interface Rel extends Operator { * @return RelType. */ @NotNull - public RelType getType(); + 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 index b877d659c..df12b26bf 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java @@ -7,35 +7,58 @@ import org.partiql.spi.function.Aggregation; import java.util.Collection; +import java.util.List; /** - * Interface for an aggregation operator. - *
- * TODO GROUP STRATEGY ISSUE + * The logical aggregation abstract base class. */ -public interface RelAggregate extends Rel { +public abstract class RelAggregate extends RelBase { + + // TODO GROUP STRATEGY: https://github.com/partiql/partiql-lang-kotlin/issues/1664 + + private final RelType type = null; + private List children = null; + + /** + * @return the input (child 0) + */ + @NotNull + public abstract Rel getInput(); @NotNull - public Rel getInput(); + public abstract Collection getMeasures(); @NotNull - public Collection getMeasures(); + public abstract Collection getGroups(); @NotNull - public Collection getGroups(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Collection getChildren(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 { + public static class Measure { private final Aggregation agg; private final Collection args; diff --git a/partiql-plan/src/main/java/org/partiql/plan/rel/RelBase.java b/partiql-plan/src/main/java/org/partiql/plan/rel/RelBase.java new file mode 100644 index 000000000..c756d5dea --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelBase.java @@ -0,0 +1,28 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operator; + +/** + * Abstract base class for all relational operators. + */ +public abstract class RelBase implements Rel { + + private int tag = 0; + + @Override + public int getTag() { + return tag; + } + + @Override + public void setTag(int tag) { + this.tag = tag; + } + + @NotNull + @Override + public Operator getChild(int index) { + return getChildren().get(index); + } +} 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 index 59e4a3402..7200c2723 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java @@ -1,24 +1,57 @@ package org.partiql.plan.rel; import org.jetbrains.annotations.NotNull; +import org.partiql.plan.JoinType; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; +import java.util.List; + /** - * Logical operator for nested-loop joins (correlated subqueries // lateral joins). + * Logical nested-loop joins (correlated subqueries // lateral joins) abstract base class. */ -public interface RelCorrelate extends Rel { +public abstract class RelCorrelate extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return the left input (child 0) + */ + @NotNull + public abstract Rel getLeft(); + + /** + * @return the right input (child 1) + */ + @NotNull + public abstract Rel getRight(); @NotNull - public Rel getLeft(); + public abstract JoinType getJoinType(); @NotNull - public Rel getRight(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rel getJoinType(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getLeft(); + Rel c1 = getRight(); + children = List.of(c0, c1); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 5f09989e9..cff6d6dc8 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java @@ -1,18 +1,46 @@ package org.partiql.plan.rel; import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; +import java.util.List; + /** - * Logical `DISTINCT` operator. + * Logical distinct operator abstract base class. */ -public interface RelDistinct extends Rel { +public abstract class RelDistinct extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return input rel (child 0) + */ + @NotNull + public abstract Rel getInput(); + + @NotNull + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rel getInput(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index a1942d883..1e339efa0 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java @@ -1,26 +1,58 @@ package org.partiql.plan.rel; import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; +import java.util.List; + /** - * Logical `EXCEPT [ALL|DISTINCT]` operator for set (or multiset) difference. + * Logical except abstract base class. */ -public interface RelExcept extends Rel { +public abstract class RelExcept extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return true if ALL else DISTINCT. + */ + public abstract boolean isAll(); + + /** + * @return left input (child 0) + */ + @NotNull + public abstract Rel getLeft(); /** - * @return true if the `ALL` keyword was used, false otherwise. + * @return right input (child 1) */ - public boolean isAll(); + @NotNull + public abstract Rel getRight(); @NotNull - public Rel getLeft(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rel getRight(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getLeft(); + Rel c1 = getRight(); + children = List.of(c0, c1); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 4190fb025..d21e9dd43 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java @@ -2,23 +2,53 @@ import org.jetbrains.annotations.NotNull; import org.partiql.plan.Exclusion; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; import java.util.Collection; +import java.util.List; /** - * Logical `EXCLUDE` operator. + * Logical exclude abstract base class. */ -public interface RelExclude extends Rel { +public abstract class RelExclude extends RelBase { + private final RelType type = null; + private List children = null; + + /** + * @return input rel (child 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return exclusions (not an operator child). + */ @NotNull - public Rel getInput(); + public abstract Collection getExclusions(); @NotNull - public Collection getExclusions(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } + + @NotNull + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index d35b1b43a..4043147f8 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java @@ -1,28 +1,55 @@ 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 java.util.List; + /** - * Logical filter operation for the WHERE and HAVING clauses. - *
- *
- *
    - *
  1. input (rel)
  2. - *
  3. predicate (rex)
  4. - *
+ * Logical filter abstract base class. */ -public interface RelFilter extends Rel { +public abstract class RelFilter extends RelBase { + + + private List children = null; + private final RelType type = null; + /** + * @return input rel (child 0) + */ @NotNull - public Rel getInput(); + public abstract Rel getInput(); + /** + * @return predicate rex (child 1) + */ @NotNull - public Rex getPredicate(); + public abstract Rex getPredicate(); + + @NotNull + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } + + @NotNull + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + Rex c1 = getPredicate(); + children = List.of(c0, c1); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 47ed477f5..63535692b 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java @@ -1,23 +1,58 @@ package org.partiql.plan.rel; import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; +import java.util.List; + /** - * Logical `INTERSECT [ALL|DISTINCT]` operator for set (or multiset) intersection. + * Logical intersect abstract base class. */ -public interface RelIntersect extends Rel { +public abstract class RelIntersect extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return true if ALL else DISTINCT. + */ + public abstract boolean isAll(); + + /** + * @return left rel (child 0) + */ + @NotNull + public abstract Rel getLeft(); - public boolean isAll(); + /** + * @return right rel (child 1) + */ + @NotNull + public abstract Rel getRight(); @NotNull - public Rel getLeft(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rel getRight(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getLeft(); + Rel c1 = getRight(); + children = List.of(c0, c1); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 03bd10e53..c290533a0 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java @@ -1,19 +1,47 @@ 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 java.util.List; + /** * Logical scan corresponding to the clause `FROM AS AT `. */ -public interface RelIterate extends Rel { +public abstract class RelIterate extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return input rex (child 0) + */ + @NotNull + public abstract Rex getRex(); + + @NotNull + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rex getRex(); + @Override + public final List getChildren() { + if (children == null) { + Rex c0 = getRex(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 03b0d60b4..da5a190d4 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java @@ -3,28 +3,58 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.partiql.plan.JoinType; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; import org.partiql.plan.rex.Rex; +import java.util.List; + /** - * Logical join operator. + * Logical join abstract base class. */ -public interface RelJoin extends Rel { +public abstract class RelJoin extends RelBase { - @NotNull - public Rel getLeft(); + private final RelType type = null; + private List children = null; + /** + * @return left input (child 0) + */ @NotNull - public Rel getRight(); + public abstract Rel getLeft(); + /** + * @return right input (child 1) + */ @NotNull - public JoinType getJoinType(); + public abstract Rel getRight(); + /** + * @return the join condition (child 2), or null if there is no condition. + */ @Nullable - public Rex getCondition(); + public abstract Rex getCondition(); + + /** + * @return JoinType + */ + @NotNull + public abstract JoinType getJoinType(); + + @NotNull + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getLeft(); + Rel c1 = getRight(); + Rex c2 = getCondition(); // can be null! + children = List.of(c0, c1, c2); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 291344d46..6c364f514 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java @@ -1,22 +1,54 @@ 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 java.util.List; + /** - * Logical `LIMIT` operator. + * Logical limit abstract base class. */ -public interface RelLimit extends Rel { +public abstract class RelLimit extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return input rel (child 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return limit rex (child 1) + */ + @NotNull + public abstract Rex getLimit(); @NotNull - public Rel getInput(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rex getLimit(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + Rex c1 = getLimit(); + children = List.of(c0, c1); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 8c8f682f9..fb7a8d883 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java @@ -1,22 +1,54 @@ 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 java.util.List; + /** - * Logical `OFFSET` operator. + * Logical offset abstract base class. */ -public interface RelOffset extends Rel { +public abstract class RelOffset extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return input rel (child 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return offset rex (child 1) + */ + @NotNull + public abstract Rex getOffset(); @NotNull - public Rel getInput(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rex getOffset(); + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + Rex c1 = getOffset(); + children = List.of(c0, c1); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 4480ffb06..4a819d984 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java @@ -1,24 +1,54 @@ 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 java.util.Collection; +import java.util.List; /** - * Logical `PROJECTION` operator + * Logical project abstract base class. */ -public interface RelProject extends Rel { +public abstract class RelProject extends RelBase { + private final RelType type = null; + private List children = null; + + /** + * @return input rel (child 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return projection (not a child, it's a list not an operator). + */ @NotNull - public Rel getInput(); + public abstract Collection getProjections(); @NotNull - public Collection getProjections(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } + + @NotNull + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getInput(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index c466e6a54..fcecf6eb1 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java @@ -1,19 +1,47 @@ 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 java.util.List; + /** - * Logical scan corresponding to the clause `FROM AS `. + * Logical scan abstract base class. */ -public interface RelScan extends Rel { +public abstract class RelScan extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return input rex (child 0) + */ + @NotNull + public abstract Rex getRex(); + + @NotNull + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rex getRex(); + @Override + public final List getChildren() { + if (children == null) { + Rex c0 = getRex(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 68cb41cdd..92f22e416 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java @@ -2,23 +2,47 @@ import org.jetbrains.annotations.NotNull; import org.partiql.plan.Collation; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; import java.util.Collection; +import java.util.List; /** - * Logical sort operator. + * Logical sort abstract base class. */ -public interface RelSort extends Rel { +public abstract class RelSort extends RelBase { + + private final RelType type = null; + private List children = null; + + @NotNull + public abstract Rel getInput(); @NotNull - public Rel getInput(); + public abstract Collection getCollations(); @NotNull - public Collection getCollations(); + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } + + @NotNull + @Override + public List getChildren() { + if (children == null) { + Rel c0 = getInput(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + 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 index 7952da872..63dc672c6 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java @@ -8,16 +8,16 @@ */ public interface RelType { - public int getFieldSize(); + int getFieldSize(); @NotNull - public Field[] getFields(); + Field[] getFields(); @NotNull - public Field getField(String name); + Field getField(String name); /** * @return true if the rel produces an ordered stream of rows. */ - public boolean isOrdered(); + 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 index bf22d6da0..15ae385c2 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnion.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnion.java @@ -1,24 +1,58 @@ package org.partiql.plan.rel; import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operator; import org.partiql.plan.Visitor; +import java.util.List; + /** - * Logical `UNION [ALL|DISTINCT]` operator for set (or multiset) union. + * Logical union abstract base class. */ -public interface RelUnion extends Rel { +public abstract class RelUnion extends RelBase { + + private final RelType type = null; + private List children = null; - public boolean isAll(); + /** + * @return true if ALL else DISTINCT. + */ + public abstract boolean isAll(); + /** + * @return left rel (child 0) + */ @NotNull - public Rel getLeft(); + public abstract Rel getLeft(); + /** + * @return right rel (child 1) + */ @NotNull - public Rel getRight(); + public abstract Rel getRight(); + @NotNull @Override - default public R accept(Visitor visitor, C ctx) { + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } + + @NotNull + @Override + public final List getChildren() { + if (children == null) { + Rel c0 = getLeft(); + Rel c1 = getRight(); + children = List.of(c0, c1); + } + return children; + } + + @Override + 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 index bc91ad415..8ca5cf21c 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnpivot.java +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnpivot.java @@ -1,19 +1,47 @@ 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 java.util.List; + /** - * Logical `UNPIVOT` operator. + * Logical unpivot abstract base class. */ -public interface RelUnpivot extends Rel { +public abstract class RelUnpivot extends RelBase { + + private final RelType type = null; + private List children = null; + + /** + * @return input rex (child 0) + */ + @NotNull + public abstract Rex getRex(); + + @NotNull + @Override + public final RelType getType() { + if (type == null) { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + return type; + } @NotNull - public Rex getRex(); + @Override + public final List getChildren() { + if (children == null) { + Rex c0 = getRex(); + children = List.of(c0); + } + return children; + } @Override - default public R accept(Visitor visitor, C ctx) { + public R accept(Visitor visitor, C ctx) { return visitor.visitUnpivot(this, ctx); } } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.java b/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.java new file mode 100644 index 000000000..211502f1d --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.java @@ -0,0 +1,13 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operator; + +/** + * A [Rex] is an [Operator] that produces a value. + */ +public interface Rex extends Operator { + + @NotNull + public RexType getType(); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.kt deleted file mode 100644 index df78b03fc..000000000 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Operator - -/** - * A [Rex] is an [Operator] that produces a value. - */ -public interface Rex : Operator { - - public fun getType(): RexType -} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.java similarity index 76% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.java index f979194d5..b202f717c 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.java @@ -9,9 +9,10 @@ public interface RexArray : Rex { public fun getValues(): Collection - override fun getChildren(): Collection = getValues().toList() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitArray(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitArray(this, ctx) } /** @@ -25,7 +26,7 @@ internal class RexArrayImpl(values: Collection, type: RexType) : RexArray { override fun getValues(): Collection = _values - override fun getChildren(): Collection = _values.toList() + override fun getType(): RexType = _type diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.java similarity index 77% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.java index 7b2acba37..735f865a5 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.java @@ -9,9 +9,10 @@ public interface RexBag : Rex { public fun getValues(): Collection - override fun getChildren(): Collection = getValues() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitBag(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitBag(this, ctx) } /** @@ -25,7 +26,7 @@ internal class RexBagImpl(values: Collection, type: RexType) : RexBag { override fun getValues(): Collection = _values - override fun getChildren(): Collection = _values + override fun getType(): RexType = _type diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.java similarity index 80% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.java index bfe39ec06..b42ef5565 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.java @@ -18,9 +18,10 @@ public fun getFunction(): Function.Instance */ public fun getArgs(): List - override fun getChildren(): Collection = getArgs() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCall(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitCall(this, ctx) } /** @@ -39,5 +40,5 @@ override fun getArgs(): List = _args override fun getType(): RexType = _type - override fun getChildren(): Collection = _args + } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.java similarity index 82% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.java index 2c85dee79..cfe96c5d6 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCallDynamic.java @@ -24,9 +24,10 @@ public fun getFunctions(): List */ public fun getArgs(): List - override fun getChildren(): Collection = getArgs() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCallDynamic(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitCallDynamic(this, ctx) } /** @@ -50,5 +51,5 @@ override fun getArgs(): List = args override fun getType(): RexType = _type - override fun getChildren(): Collection = args + } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.java similarity index 92% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.java index 4d6a665ba..697a8b56b 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.java @@ -13,9 +13,10 @@ public fun getBranches(): List public fun getDefault(): Rex? - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCase(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitCase(this, ctx) - override fun getChildren(): Collection { + val children = mutableListOf() val match = getMatch() val branches = getBranches() @@ -60,7 +61,7 @@ override fun getBranches(): List = _branches override fun getDefault(): Rex? = _default - override fun getChildren(): Collection { + if (_children == null) { _children = super.getChildren() } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.java similarity index 85% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.java index 96f21fb20..ced96be5d 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.java @@ -12,9 +12,10 @@ public fun getOperand(): Rex public fun getTarget(): PType - override fun getChildren(): Collection = listOf(getOperand()) + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCast(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitCast(this, ctx) } /** @@ -32,7 +33,7 @@ override fun getOperand(): Rex = _operand override fun getTarget(): PType = _target - override fun getChildren(): Collection { + if (_children == null) { _children = listOf(_operand) } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.java similarity index 76% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.java index aa7cef41a..af7b0550e 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.java @@ -9,9 +9,10 @@ public interface RexCoalesce : Rex { public fun getArgs(): List - override fun getChildren(): Collection = getArgs() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCoalesce(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitCoalesce(this, ctx) } internal class RexCoalesceImpl(args: List, type: RexType) : RexCoalesce { @@ -22,7 +23,7 @@ internal class RexCoalesceImpl(args: List, type: RexType) : RexCoalesce { override fun getArgs(): List = _args - override fun getChildren(): Collection = _args + override fun getType(): RexType = _type diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.java similarity index 68% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexError.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexError.java index b8c018662..7467d72e5 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.java @@ -10,9 +10,10 @@ public interface RexError : Rex { override fun getType(): RexType = RexType.dynamic() - override fun getChildren(): Collection = emptyList() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitError(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitError(this, ctx) } internal class RexErrorImpl : RexError diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.java similarity index 81% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.java index 954b0fe6d..fb8b0591e 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.java @@ -10,9 +10,10 @@ public interface RexLit : Rex { public fun getValue(): Datum - override fun getChildren(): Collection = emptyList() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitLit(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitLit(this, ctx) } internal class RexLitImpl(value: Datum) : RexLit { diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.java similarity index 79% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.java index 9f98216cb..a371df6a1 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.java @@ -11,9 +11,10 @@ public fun getV1(): Rex public fun getV2(): Rex - override fun getChildren(): Collection = listOf(getV1(), getV2()) + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitNullIf(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitNullIf(this, ctx) } /** @@ -31,7 +32,7 @@ override fun getV2(): Rex = _v2 override fun getType(): RexType = _v1.getType() - override fun getChildren(): Collection = listOf(_v1, _v2) + override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.java similarity index 77% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.java index 926e1f0a7..53d4f8003 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.java @@ -11,7 +11,8 @@ public fun getOperand(): Rex public fun getIndex(): Rex - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPathIndex(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitPathIndex(this, ctx) } /** @@ -30,5 +31,5 @@ override fun getIndex() = _index override fun getType(): RexType = _type - override fun getChildren(): Collection = listOf(_operand, _index) + } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.java similarity index 77% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.java index 97d27ddda..b59243a31 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.java @@ -11,7 +11,8 @@ public fun getOperand(): Rex public fun getKey(): Rex - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPathKey(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitPathKey(this, ctx) } /** @@ -30,5 +31,5 @@ override fun getKey() = _key override fun getType(): RexType = _type - override fun getChildren(): Collection = listOf(_operand, _key) + } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.java similarity index 79% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.java index 2b4d400e7..0b9275568 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.java @@ -11,7 +11,8 @@ public fun getOperand(): Rex public fun getSymbol(): String - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPathSymbol(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitPathSymbol(this, ctx) } /** @@ -30,5 +31,5 @@ override fun getSymbol() = _symbol override fun getType(): RexType = _type - override fun getChildren(): Collection = listOf(_operand) + } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.java similarity index 87% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.java index 05c6bd900..b41e85670 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.java @@ -15,9 +15,10 @@ public fun getKey(): Rex public fun getValue(): Rex - override fun getChildren(): Collection = listOf(getKey(), getValue()) + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPivot(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitPivot(this, ctx) } /** @@ -46,7 +47,7 @@ override fun getType(): RexType { return RexType(type!!) } - override fun getChildren(): Collection { + if (children == null) { children = listOf(getKey(), getValue()) } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.java similarity index 84% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.java index 95096cc87..4ec74c5eb 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.java @@ -13,9 +13,10 @@ public fun getInput(): Rel public fun getConstructor(): Rex - override fun getChildren(): Collection = listOf(getConstructor()) + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSelect(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitSelect(this, ctx) } internal class RexSelectImpl(input: Rel, constructor: Rex) : RexSelect { @@ -41,7 +42,7 @@ override fun getType(): RexType { return _type!! } - override fun getChildren(): Collection = listOf(_constructor) + override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.java similarity index 84% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.java index f4157f8c4..4515b9969 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.java @@ -9,9 +9,10 @@ public interface RexSpread : Rex { public fun getArgs(): List - override fun getChildren(): Collection = getArgs() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSpread(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitSpread(this, ctx) } /** diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.java similarity index 87% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.java index 3ad4cfffc..ec178cac1 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.java @@ -9,7 +9,7 @@ public interface RexStruct : Rex { public fun getFields(): List - override fun getChildren(): Collection { + val children = mutableListOf() for (field in getFields()) { children.add(field.getKey()) @@ -18,7 +18,8 @@ override fun getChildren(): Collection { return children } - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitStruct(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitStruct(this, ctx) /** * TODO DOCUMENTATION @@ -46,7 +47,7 @@ override fun getFields(): List = _fields override fun getType(): RexType = _type - override fun getChildren(): Collection { + if (_children == null) { _children = super.getChildren() } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.java similarity index 89% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.java index 9d94538ea..3250bc70e 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.java @@ -15,7 +15,8 @@ public fun getConstructor(): Rex // TODO REMOVE ME – TEMPORARY UNTIL PLANNER PROPERLY HANDLES SUBQUERIES public fun asScalar(): Boolean - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubquery(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitSubquery(this, ctx) } /** @@ -38,7 +39,7 @@ override fun getType(): RexType { TODO("Not yet implemented") } - override fun getChildren(): Collection { + TODO("Not yet implemented") } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.java similarity index 91% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.java index 7d9ae0093..799b64b13 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.java @@ -21,7 +21,8 @@ public fun getQuantifier(): Quantifier? public fun getRel(): Rel - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubqueryComp(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitSubqueryComp(this, ctx) /** * SQL for use in the . @@ -79,7 +80,7 @@ override fun getQuantifier(): Quantifier? = _quantifier override fun getRel(): Rel = _rel - override fun getChildren(): Collection = _args + // TODO hashcode/equals? } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.java similarity index 80% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.java index c742274a0..704439274 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.java @@ -9,7 +9,8 @@ public fun getArgs(): List public fun getRel(): Rel - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubqueryIn(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitSubqueryIn(this, ctx) } /** @@ -29,7 +30,7 @@ override fun getArgs(): List = _args override fun getRel(): Rel = _rel - override fun getChildren(): Collection = _args + // TODO hashcode/equals? } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.java similarity index 87% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.java index 9ad2ab6bd..fb398ac1c 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.java @@ -15,7 +15,8 @@ public fun getTest(): Test public fun getRel(): org.partiql.plan.rel.Rel - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubqueryTest(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitSubqueryTest(this, ctx) /** * EXISTS and UNIQUE are defined by SQL. @@ -48,7 +49,7 @@ override fun getTest(): Test = _test override fun getRel(): org.partiql.plan.rel.Rel = _rel - override fun getChildren(): Collection = emptyList() + // TODO hashcode/equals? } diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.java similarity index 84% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.java index 8bef45722..b36085481 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.java @@ -10,9 +10,10 @@ public interface RexTable : Rex { public fun getTable(): Table - override fun getChildren(): Collection = emptyList() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitTable(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitTable(this, ctx) } /** diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexType.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexType.java similarity index 100% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexType.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexType.java diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.kt b/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.java similarity index 87% rename from partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.kt rename to partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.java index 709626dc3..8ddc4309b 100644 --- a/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.java @@ -18,9 +18,10 @@ public fun getDepth(): Int */ public fun getOffset(): Int - override fun getChildren(): Collection = emptyList() + - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitVar(this, ctx) + @Override + default public R accept(Visitor visitor, C ctx) { = visitor.visitVar(this, ctx) } /** diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/PlanFactory.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/builder/PlanFactory.kt index ed9b9eaab..b901d12d2 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/PlanFactory.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/builder/PlanFactory.kt @@ -7,38 +7,38 @@ import org.partiql.plan.JoinType import org.partiql.plan.RelAggregateCallImpl import org.partiql.plan.rel.Rel import org.partiql.plan.rel.RelAggregate -import org.partiql.plan.rel.RelAggregateImpl +import org.partiql.plan.impl.RelAggregateImpl import org.partiql.plan.rel.RelCorrelate -import org.partiql.plan.rel.RelCorrelateImpl +import org.partiql.plan.impl.RelCorrelateImpl import org.partiql.plan.rel.RelDistinct -import org.partiql.plan.rel.RelDistinctImpl +import org.partiql.plan.impl.RelDistinctImpl import org.partiql.plan.rel.RelExcept -import org.partiql.plan.rel.RelExceptImpl +import org.partiql.plan.impl.RelExceptImpl import org.partiql.plan.rel.RelExclude -import org.partiql.plan.rel.RelExcludeImpl +import org.partiql.plan.impl.RelExcludeImpl import org.partiql.plan.rel.RelFilter -import org.partiql.plan.rel.RelFilterImpl +import org.partiql.plan.impl.RelFilterImpl import org.partiql.plan.rel.RelIntersect -import org.partiql.plan.rel.RelIntersectImpl +import org.partiql.plan.impl.RelIntersectImpl import org.partiql.plan.rel.RelIterate -import org.partiql.plan.rel.RelIterateImpl +import org.partiql.plan.impl.RelIterateImpl import org.partiql.plan.rel.RelJoin -import org.partiql.plan.rel.RelJoinImpl +import org.partiql.plan.impl.RelJoinImpl import org.partiql.plan.rel.RelLimit -import org.partiql.plan.rel.RelLimitImpl +import org.partiql.plan.impl.RelLimitImpl import org.partiql.plan.rel.RelOffset -import org.partiql.plan.rel.RelOffsetImpl +import org.partiql.plan.impl.RelOffsetImpl import org.partiql.plan.rel.RelProject -import org.partiql.plan.rel.RelProjectImpl +import org.partiql.plan.impl.RelProjectImpl import org.partiql.plan.rel.RelScan -import org.partiql.plan.rel.RelScanImpl +import org.partiql.plan.impl.RelScanImpl import org.partiql.plan.rel.RelSort -import org.partiql.plan.rel.RelSortImpl +import org.partiql.plan.impl.RelSortImpl import org.partiql.plan.rel.RelType import org.partiql.plan.rel.RelUnion -import org.partiql.plan.rel.RelUnionImpl +import org.partiql.plan.impl.RelUnionImpl import org.partiql.plan.rel.RelUnpivot -import org.partiql.plan.rel.RelUnpivotImpl +import org.partiql.plan.impl.RelUnpivotImpl import org.partiql.plan.rex.Rex import org.partiql.plan.rex.RexArray import org.partiql.plan.rex.RexArrayImpl diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt deleted file mode 100644 index f4274ca9c..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelDistinctImpl.kt +++ /dev/null @@ -1,35 +0,0 @@ -package org.partiql.plan.rel - -/** - * Default [RelDistinct] implementation. - */ -internal class RelDistinctImpl(input: Rel) : RelDistinct { - - // DO NOT USE FINAL - private var _input: Rel = input - private var _children: List? = null - private var _ordered: Boolean = input.isOrdered() - - override fun getInput(): Rel = _input - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_input) - } - return _children!! - } - - override fun getType(): RelType = _input.getType() - - override fun isOrdered(): Boolean = _ordered - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || other !is RelDistinct) return false - return _input == other.getInput() - } - - override fun hashCode(): Int { - return _input.hashCode() - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt deleted file mode 100644 index 42ca73359..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExceptImpl.kt +++ /dev/null @@ -1,49 +0,0 @@ -package org.partiql.plan.rel - -/** - * Default [RelExcept] implementation. - */ -internal class RelExceptImpl(left: Rel, right: Rel, isAll: Boolean) : - RelExcept { - - // DO NOT USE FINAL - private var _isAll = isAll - private var _left = left - private var _right = right - private var _children: List? = null - - override fun isAll(): Boolean = _isAll - - override fun getLeft(): Rel = _left - - override fun getRight(): Rel = _right - - 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 RelExcept) return false - if (_isAll != other.isAll()) return false - if (_left != other.getLeft()) return false - if (_right != other.getRight()) return false - return true - } - - override fun hashCode(): Int { - var result = _isAll.hashCode() - result = 31 * result + _left.hashCode() - 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/RelExcludeImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExcludeImpl.kt deleted file mode 100644 index 82af2847a..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelExcludeImpl.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.Exclusion - -/** - * Default [RelExclude] implementation. - */ -internal class RelExcludeImpl(input: Rel, exclusions: List) : RelExclude { - - // DO NOT USE FINAL - private var _input: Rel = input - private var _exclusions: List = exclusions - private var _ordered: Boolean = input.isOrdered() - - override fun getInput(): Rel = _input - - override fun getChildren(): Collection = listOf(_input) - - override fun getExclusions(): List = _exclusions - - override fun isOrdered(): Boolean = _ordered - - override fun getType(): RelType { - TODO("Not yet implemented") - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelExclude) return false - if (_input != other.getInput()) return false - if (_exclusions != other.getExclusions()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _exclusions.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt deleted file mode 100644 index 3d603dc55..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelFilterImpl.kt +++ /dev/null @@ -1,45 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.rex.Rex - -/** - * Default [RelFilter] implementation. - */ -internal class RelFilterImpl(input: Rel, predicate: Rex) : RelFilter { - - // DO NOT USE FINAL - private var _input: Rel = input - private var _children: List? = null - private var _predicate: Rex = predicate - private var _ordered: Boolean = input.isOrdered() - - override fun getInput(): Rel = _input - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_input) - } - return _children!! - } - - override fun getPredicate(): Rex = _predicate - - override fun getType(): RelType = _input.getType() - - override fun isOrdered(): Boolean = _ordered - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelFilter) return false - if (_input != other.getInput()) return false - if (_predicate != other.getPredicate()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _predicate.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt deleted file mode 100644 index 9877701d9..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIntersectImpl.kt +++ /dev/null @@ -1,49 +0,0 @@ -package org.partiql.plan.rel - -/** - * Default [RelIntersect] implementation. - */ -internal class RelIntersectImpl(left: Rel, right: Rel, isAll: Boolean) : - RelIntersect { - - // DO NOT USE FINAL - private var _isAll = isAll - private var _left = left - private var _right = right - private var _children: List? = null - - override fun isAll(): Boolean = _isAll - - override fun getLeft(): Rel = _left - - override fun getRight(): Rel = _right - - 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 RelIntersect) return false - if (_isAll != other.isAll()) return false - if (_left != other.getLeft()) return false - if (_right != other.getRight()) return false - return true - } - - override fun hashCode(): Int { - var result = _isAll.hashCode() - result = 31 * result + _left.hashCode() - 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/RelIterateImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIterateImpl.kt deleted file mode 100644 index f5c81ce0a..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelIterateImpl.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.rex.Rex - -/** - * Default [RelIterate] implementation. - */ -internal class RelIterateImpl(input: Rex) : RelIterate { - - // DO NOT USE FINAL - private var _input: Rex = input - - override fun getInput(): Rex = _input - - override fun getType(): RelType { - TODO("Implement getSchema for scan") - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || other !is RelIterate) return false - return _input == other.getInput() - } - - override fun hashCode(): Int { - return _input.hashCode() - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt deleted file mode 100644 index 9262aec3f..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelJoinImpl.kt +++ /dev/null @@ -1,71 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.JoinType -import org.partiql.plan.rex.Rex - -/** - * Default [RelJoin] implementation. - */ -internal class RelJoinImpl( - left: Rel, - right: Rel, - condition: Rex?, - joinType: JoinType, - leftSchema: RelType?, - rightSchema: RelType?, -) : RelJoin { - - // DO NOT USE FINAL - private var _left = left - private var _right = right - private var _condition = condition - private var _joinType = joinType - private var _leftSchema = leftSchema - private var _rightSchema = rightSchema - - private var _children: List? = null - - override fun getLeft(): Rel = _left - - override fun getRight(): Rel = _right - - override fun getCondition(): Rex? = _condition - - override fun getJoinType(): JoinType = _joinType - - override fun getLeftSchema(): RelType? = _leftSchema - - override fun getRightSchema(): RelType? = _rightSchema - - 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 RelJoin) return false - if (_left != other.getLeft()) return false - if (_right != other.getRight()) return false - if (_condition != other.getCondition()) 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 + _condition.hashCode() - result = 31 * result + _joinType.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt deleted file mode 100644 index 411e8b889..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelLimitImpl.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.rex.Rex - -/** - * Default [RelLimit] implementation. - */ -internal class RelLimitImpl(input: Rel, limit: Rex) : RelLimit { - - // DO NOT USE FINAL - private var _input: Rel = input - private var _limit: Rex = limit - - override fun getInput(): Rel = _input - - override fun getLimit(): Rex = _limit - - override fun getChildren(): Collection = listOf(_input) - - override fun getType(): RelType = _input.getType() - - override fun isOrdered(): Boolean = _input.isOrdered() - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelLimit) return false - if (_input != other.getInput()) return false - if (_limit != other.getLimit()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _limit.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt deleted file mode 100644 index f6feb64d8..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelOffsetImpl.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.rex.Rex - -/** - * Default [RelOffset] implementation. - */ -internal class RelOffsetImpl(input: Rel, offset: Rex) : RelOffset { - - // DO NOT USE FINAL - private var _input: Rel = input - private var _offset: Rex = offset - - override fun getInput(): Rel = _input - - override fun getOffset(): Rex = _offset - - override fun getChildren(): Collection = listOf(_input) - - override fun getType(): RelType = _input.getType() - - override fun isOrdered(): Boolean = _input.isOrdered() - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelOffset) return false - if (_input != other.getInput()) return false - if (_offset != other.getOffset()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _offset.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt deleted file mode 100644 index 3d9173950..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelProjectImpl.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.rex.Rex - -/** - * Default [RelProject] implementation. - */ -public class RelProjectImpl(input: Rel, projections: List) : RelProject { - - // DO NOT USE FINAL - private var _input = input - private var _projections = projections - - override fun getInput(): Rel = _input - - override fun getProjections(): List = _projections - - override fun getType(): RelType { - TODO("Not yet implemented") - } - - override fun getChildren(): Collection = listOf(_input) - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelProject) return false - if (_input != other.getInput()) return false - if (_projections != other.getProjections()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _projections.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt deleted file mode 100644 index 9485afb62..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelScanImpl.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.rex.Rex - -/** - * Default [RelScan] implementation. - */ -internal class RelScanImpl(input: Rex) : RelScan { - - // DO NOT USE FINAL - private var _input: Rex = input - - override fun getInput(): Rex = _input - - override fun getType(): RelType { - TODO("Implement getSchema for scan") - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || other !is RelScan) return false - return _input == other.getInput() - } - - override fun hashCode(): Int { - return _input.hashCode() - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt deleted file mode 100644 index bd3d1ae90..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelSortImpl.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.partiql.plan.rel - -import org.partiql.plan.Collation - -/** - * Default [RelSort] implementation. - */ -internal class RelSortImpl(input: Rel, collations: List) : RelSort { - - // DO NOT USE FINAL - private var _input = input - private var _collations = collations - - private var _children: List? = null - - override fun getInput(): Rel = _input - - override fun getCollations(): List = _collations - - override fun getType(): RelType = _input.getType() - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_input) - } - return _children!! - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelSort) return false - if (_input != other.getInput()) return false - if (_collations != other.getCollations()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _collations.hashCode() - return result - } -} \ No newline at end of file diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt deleted file mode 100644 index bb80676cb..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnionImpl.kt +++ /dev/null @@ -1,49 +0,0 @@ -package org.partiql.plan.rel - -/** - * Default [RelUnion] implementation. - */ -internal class RelUnionImpl(left: Rel, right: Rel, isAll: Boolean) : - RelUnion { - - // DO NOT USE FINAL - private var _isAll = isAll - private var _left = left - private var _right = right - private var _children: List? = null - - override fun isAll(): Boolean = _isAll - - override fun getLeft(): Rel = _left - - override fun getRight(): Rel = _right - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_left, _right) - } - return _children!! - } - - override fun isOrdered(): Boolean = false - - override fun getType(): RelType { - TODO("Not yet implemented") - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RelUnion) return false - if (_isAll != other.isAll()) return false - if (_left != other.getLeft()) return false - if (_right != other.getRight()) return false - return true - } - - override fun hashCode(): Int { - var result = _isAll.hashCode() - result = 31 * result + _left.hashCode() - 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 deleted file mode 100644 index 112cd10a9..000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/impl/RelUnpivotImpl.kt +++ /dev/null @@ -1,2 +0,0 @@ -package org.partiql.plan.rel -