diff --git a/docs/wiki/v1/compiler.md b/docs/wiki/v1/compiler.md index 43f94e2927..c86da18b04 100644 --- a/docs/wiki/v1/compiler.md +++ b/docs/wiki/v1/compiler.md @@ -60,8 +60,8 @@ I have labelled these children in the illustration so that you can see where the RelLimit / \ x: RelOffset - / \ - y: z: + / \ + y: z: ``` The compiler will look for this pattern in the operator tree, and produce a match like so, diff --git a/partiql-ast/README.adoc b/partiql-ast/README.adoc index 40935b00b3..e8599de806 100644 --- a/partiql-ast/README.adoc +++ b/partiql-ast/README.adoc @@ -345,7 +345,7 @@ The Visitor pattern is the most widely misunderstood pattern in all of Design Pa The trouble starts with terminology. The pattern isn’t about “visiting”, and the “accept” method in it doesn’t conjure up any helpful imagery either. Many think the pattern has to do with traversing trees, which isn’t the case at all. We are going to use it on a set of classes that are tree-like, but that’s a coincidence. As you’ll see, the pattern works as well on a single object. -The Visitor pattern is really about approximating the functional style within an OOP language. It lets us add new columns to that table easily. We can define all of the behavior for a new operation on a set of types in one place, without having to touch the types themselves. It does this the same way we solve almost every problem in computer science: by adding a layer of indirection. +The Visitor pattern is really about approximating the functional style within an OOP language. It lets us add new columns to that table easily. We can define all of the behavior for a new action on a set of types in one place, without having to touch the types themselves. It does this the same way we solve almost every problem in computer science: by adding a layer of indirection. -- Robert Nystrom, Crafting Interpreters ____ diff --git a/partiql-eval/api/partiql-eval.api b/partiql-eval/api/partiql-eval.api index bf609d0d54..60e5c7812f 100644 --- a/partiql-eval/api/partiql-eval.api +++ b/partiql-eval/api/partiql-eval.api @@ -45,9 +45,8 @@ public abstract interface class org/partiql/eval/Statement { } public class org/partiql/eval/compiler/Match { - public fun (Lorg/partiql/plan/Operator;Ljava/util/List;)V - public fun children (I)Ljava/util/List; - public fun operator (I)Lorg/partiql/plan/Operator; + public fun (Lorg/partiql/plan/Operand;)V + public fun getOperand ()Lorg/partiql/plan/Operand; } public abstract interface class org/partiql/eval/compiler/PartiQLCompiler { @@ -70,7 +69,11 @@ public class org/partiql/eval/compiler/Pattern { public abstract class org/partiql/eval/compiler/Strategy { public fun (Lorg/partiql/eval/compiler/Pattern;)V - public abstract fun apply (Lorg/partiql/eval/compiler/Match;)Lorg/partiql/eval/Expr; + public abstract fun apply (Lorg/partiql/eval/compiler/Match;Lorg/partiql/eval/Mode;Lorg/partiql/eval/compiler/Strategy$Callback;)Lorg/partiql/eval/Expr; public fun getPattern ()Lorg/partiql/eval/compiler/Pattern; } +public abstract interface class org/partiql/eval/compiler/Strategy$Callback { + public abstract fun apply (Lorg/partiql/plan/Operator;)Lorg/partiql/eval/Expr; +} + diff --git a/partiql-eval/src/main/java/org/partiql/eval/compiler/Match.java b/partiql-eval/src/main/java/org/partiql/eval/compiler/Match.java index de099a8579..25066085bb 100644 --- a/partiql-eval/src/main/java/org/partiql/eval/compiler/Match.java +++ b/partiql-eval/src/main/java/org/partiql/eval/compiler/Match.java @@ -1,50 +1,31 @@ package org.partiql.eval.compiler; import org.jetbrains.annotations.NotNull; -import org.partiql.eval.Expr; -import org.partiql.plan.Operator; - -import java.util.Collections; -import java.util.List; +import org.partiql.plan.Operand; /** * Match represents a subtree match to be sent to the */ public class Match { - private final Operator[] operators; - private final List> children; + private final Operand[] operands; /** - * Single operator match with zero-or-more inputs. + * Single operand match with zero-or-more inputs. * - * @param operator matched logical operator. - * @param children compiled child operators. + * @param operand matched logical operand. */ - public Match(@NotNull Operator operator, @NotNull List children) { - this.operators = new Operator[]{operator}; - this.children = Collections.singletonList(children); - } - - /** - * Get the i-th operator (pre-order) matched by the pattern. - * - * @param i 0-indexed - * @return Operator - */ - @NotNull - public Operator operator(int i) { - return operators[i]; + public Match(@NotNull Operand operand) { + this.operands = new Operand[]{operand}; } /** - * Get the i-th input to this pattern. + * Get the first (or only) operand * - * @param i 0-indexed - * @return Expr + * @return Operand */ @NotNull - public List children(int i) { - return children.get(i); + public Operand getOperand() { + return operands[0]; } } diff --git a/partiql-eval/src/main/java/org/partiql/eval/compiler/Strategy.java b/partiql-eval/src/main/java/org/partiql/eval/compiler/Strategy.java index 34ad6fdbf6..5593c4d2d4 100644 --- a/partiql-eval/src/main/java/org/partiql/eval/compiler/Strategy.java +++ b/partiql-eval/src/main/java/org/partiql/eval/compiler/Strategy.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; import org.partiql.eval.Expr; +import org.partiql.eval.Mode; import org.partiql.plan.Operator; /** @@ -34,8 +35,22 @@ public Pattern getPattern() { * Applies the strategy to a logical plan operator and returns the physical operation (expr). * * @param match holds the matched operators + * @param mode evaluation mode + * @param callback for compiling arguments of matched operators * @return the physical operation */ @NotNull - public abstract Expr apply(@NotNull Match match); + public abstract Expr apply(@NotNull Match match, @NotNull Mode mode, @NotNull Callback callback); + + /** + * A compilation callback for strategies to compile arguments of matched operators. + */ + public interface Callback { + + /** + * @return a physical operator (expr) for the logical operator. + */ + @NotNull + Expr apply(@NotNull Operator operator); + } } 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 b7e8f70f6e..1bea972c21 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 @@ -59,12 +59,13 @@ import org.partiql.eval.internal.operator.rex.ExprSubquery import org.partiql.eval.internal.operator.rex.ExprSubqueryRow import org.partiql.eval.internal.operator.rex.ExprTable import org.partiql.eval.internal.operator.rex.ExprVar +import org.partiql.plan.Action import org.partiql.plan.Collation import org.partiql.plan.JoinType -import org.partiql.plan.Operation +import org.partiql.plan.Operand import org.partiql.plan.Operator +import org.partiql.plan.OperatorVisitor import org.partiql.plan.Plan -import org.partiql.plan.Visitor import org.partiql.plan.rel.Rel import org.partiql.plan.rel.RelAggregate import org.partiql.plan.rel.RelDistinct @@ -85,10 +86,10 @@ import org.partiql.plan.rex.Rex import org.partiql.plan.rex.RexArray import org.partiql.plan.rex.RexBag import org.partiql.plan.rex.RexCall -import org.partiql.plan.rex.RexCallDynamic import org.partiql.plan.rex.RexCase import org.partiql.plan.rex.RexCast import org.partiql.plan.rex.RexCoalesce +import org.partiql.plan.rex.RexDispatch import org.partiql.plan.rex.RexError import org.partiql.plan.rex.RexLit import org.partiql.plan.rex.RexNullIf @@ -123,10 +124,10 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { override fun prepare(plan: Plan, mode: Mode, ctx: Context): Statement { try { - val visitor = _Visitor(mode) - val operation = plan.getOperation() + val visitor = Visitor(mode) + val operation = plan.action val statement: Statement = when { - operation is Operation.Query -> visitor.compile(operation) + operation is Action.Query -> visitor.compile(operation) else -> throw IllegalArgumentException("Only query statements are supported") } return statement @@ -142,18 +143,18 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { /** * Transforms plan relation operators into the internal physical operators. */ - @Suppress("ClassName") - private inner class _Visitor(mode: Mode) : Visitor { + private inner class Visitor(mode: Mode) : OperatorVisitor { - private val mode = mode.code() + private val mode = mode + private val MODE = mode.code() /** * Compile a query operation to a query statement. */ - fun compile(operation: Operation.Query) = object : Statement { + fun compile(action: Action.Query) = object : Statement { // compile the query root - private val root = compile(operation.getRex(), Unit).catch() + private val root = compile(action.getRex(), Unit).catch() // execute with no parameters override fun execute(): Datum = root.eval(Environment()) @@ -167,25 +168,25 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { * @param operator * @return */ - private fun compileWithStrategies(operator: Operator, ctx: Unit): Expr { + private fun compileWithStrategies(operator: Operator): Expr { // if strategy matches root, compile children to form a match. for (strategy in strategies) { // first match - if (strategy.getPattern().matches(operator)) { - // compile children - val children = operator.getChildren().map { compileWithStrategies(it, ctx) } - val match = Match(operator, children) - return strategy.apply(match) + if (strategy.pattern.matches(operator)) { + // assume single match + val operand = Operand.single(operator) + val match = Match(operand) + return strategy.apply(match, mode, ::compileWithStrategies) } } return operator.accept(this, Unit) } // TODO REMOVE ME - private fun compile(rel: Rel, ctx: Unit): ExprRelation = compileWithStrategies(rel, ctx) as ExprRelation + private fun compile(rel: Rel, ctx: Unit): ExprRelation = compileWithStrategies(rel) as ExprRelation // TODO REMOVE ME - private fun compile(rex: Rex, ctx: Unit): ExprValue = compileWithStrategies(rex, ctx) as ExprValue + private fun compile(rex: Rex, ctx: Unit): ExprValue = compileWithStrategies(rex) as ExprValue override fun defaultReturn(operator: Operator, ctx: Unit): Expr { error("No compiler strategy matches the operator: ${operator::class.java.simpleName}") @@ -195,7 +196,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,28 +242,29 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { } override fun visitIterate(rel: RelIterate, ctx: Unit): ExprRelation { - val input = compile(rel.getInput(), ctx) - return when (mode) { + val input = compile(rel.getRex(), ctx) + return when (MODE) { Mode.PERMISSIVE -> RelOpIteratePermissive(input) Mode.STRICT -> RelOpIterate(input) - else -> throw IllegalStateException("Unsupported execution mode: $mode") + else -> throw IllegalStateException("Unsupported execution mode: $MODE") } } override fun visitJoin(rel: RelJoin, ctx: Unit): ExprRelation { - val lhs = compile(rel.getLeft(), ctx) - val rhs = compile(rel.getRight(), ctx) - val condition = rel.getCondition()?.let { compile(it, ctx) } ?: ExprLit(Datum.bool(true)) - - // TODO JOIN SCHEMAS - val lhsType = rel.getLeftSchema() - val rhsType = rel.getRightSchema() - - return when (rel.getJoinType()) { + val lrel = rel.left + val rrel = rel.right + val lhs = compile(lrel, ctx) + val rhs = compile(rrel, ctx) + val condition = compile(rel.getCondition(), ctx) + // use schema for null padding + val lhsType = lrel.type + val rhsType = rrel.type + return when (rel.joinType.code()) { JoinType.INNER -> RelOpJoinInner(lhs, rhs, condition) - JoinType.LEFT -> RelOpJoinOuterLeft(lhs, rhs, condition, rhsType!!) - JoinType.RIGHT -> RelOpJoinOuterRight(lhs, rhs, condition, lhsType!!) - JoinType.FULL -> RelOpJoinOuterFull(lhs, rhs, condition, lhsType!!, rhsType!!) + JoinType.LEFT -> RelOpJoinOuterLeft(lhs, rhs, condition, rhsType) + JoinType.RIGHT -> RelOpJoinOuterRight(lhs, rhs, condition, lhsType) + JoinType.FULL -> RelOpJoinOuterFull(lhs, rhs, condition, lhsType, rhsType) + else -> error("Unsupported join type: ${rel.joinType}") } } @@ -285,20 +287,20 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { } override fun visitScan(rel: RelScan, ctx: Unit): ExprRelation { - val input = compile(rel.getInput(), ctx) - return when (mode) { + val input = compile(rel.rex, ctx) + return when (MODE) { Mode.PERMISSIVE -> RelOpScanPermissive(input) Mode.STRICT -> RelOpScan(input) - else -> throw IllegalStateException("Unsupported execution mode: $mode") + else -> throw IllegalStateException("Unsupported execution mode: $MODE") } } override fun visitSort(rel: RelSort, ctx: Unit): ExprRelation { val input = compile(rel.getInput(), ctx) val collations = rel.getCollations().map { - val expr = compile(it.getRex(), ctx) - val desc = it.getOrder() == Collation.Order.DESC - val last = it.getNulls() == Collation.Nulls.LAST + val expr = compile(it.column, ctx) + val desc = it.order.code() == Collation.Order.DESC + val last = it.nulls.code() == Collation.Nulls.LAST RelOpSort.Collation(expr, desc, last) } return RelOpSort(input, collations) @@ -314,11 +316,11 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { } override fun visitUnpivot(rel: RelUnpivot, ctx: Unit): ExprRelation { - val input = compile(rel.getInput(), ctx) - return when (mode) { + val input = compile(rel.rex, ctx) + return when (MODE) { Mode.PERMISSIVE -> RelOpUnpivot.Permissive(input) Mode.STRICT -> RelOpUnpivot.Strict(input) - else -> throw IllegalStateException("Unsupported execution mode: $mode") + else -> throw IllegalStateException("Unsupported execution mode: $MODE") } } @@ -338,7 +340,7 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { return ExprBag(values) } - override fun visitCallDynamic(rex: RexCallDynamic, ctx: Unit): ExprValue { + override fun visitDispatch(rex: RexDispatch, ctx: Unit): ExprValue { // Check candidate arity for uniformity var arity: Int = -1 val name = rex.getName() @@ -401,7 +403,7 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { } override fun visitLit(rex: RexLit, ctx: Unit): ExprValue { - return ExprLit(rex.getValue()) + return ExprLit(rex.getDatum()) } override fun visitNullIf(rex: RexNullIf, ctx: Unit): ExprValue { @@ -432,37 +434,37 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { val input = compile(rex.getInput(), ctx) val key = compile(rex.getKey(), ctx) val value = compile(rex.getValue(), ctx) - return when (mode) { + return when (MODE) { Mode.PERMISSIVE -> ExprPivotPermissive(input, key, value) Mode.STRICT -> ExprPivot(input, key, value) - else -> throw IllegalStateException("Unsupported execution mode: $mode") + else -> throw IllegalStateException("Unsupported execution mode: $MODE") } } override fun visitSelect(rex: RexSelect, ctx: Unit): ExprValue { val input = compile(rex.getInput(), ctx) val constructor = compile(rex.getConstructor(), ctx).catch() - val ordered = rex.getInput().isOrdered() + val ordered = rex.getInput().type.isOrdered return ExprSelect(input, constructor, ordered) } override fun visitStruct(rex: RexStruct, ctx: Unit): ExprValue { val fields = rex.getFields().map { - val k = compile(it.getKey(), ctx) - val v = compile(it.getValue(), ctx).catch() + val k = compile(it.key, ctx) + val v = compile(it.value, ctx).catch() ExprStructField(k, v) } - return when (mode) { + return when (MODE) { Mode.PERMISSIVE -> ExprStructPermissive(fields) Mode.STRICT -> ExprStructStrict(fields) - else -> throw IllegalStateException("Unsupported execution mode: $mode") + else -> throw IllegalStateException("Unsupported execution mode: $MODE") } } override fun visitSubquery(rex: RexSubquery, ctx: Unit): ExprValue { - val rel = compile(rex.getRel(), ctx) + val rel = compile(rex.getInput(), ctx) val constructor = compile(rex.getConstructor(), ctx) - return when (rex.asScalar()) { + return when (rex.isScalar()) { true -> ExprSubquery(rel, constructor) else -> ExprSubqueryRow(rel, constructor) } @@ -490,18 +492,18 @@ internal class StandardCompiler(strategies: List) : PartiQLCompiler { } override fun visitVar(rex: RexVar, ctx: Unit): ExprValue { - val depth = rex.getDepth() + val scope = rex.scope val offset = rex.getOffset() - return ExprVar(depth, offset) + return ExprVar(scope, offset) } /** * Some places "catch" an error and return the MISSING value. */ - private fun ExprValue.catch(): ExprValue = when (mode) { + private fun ExprValue.catch(): ExprValue = when (MODE) { Mode.PERMISSIVE -> ExprPermissive(this) Mode.STRICT -> this - else -> throw IllegalStateException("Unsupported execution mode: $mode") + else -> throw IllegalStateException("Unsupported execution mode: $MODE") } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelOpJoinOuterFull.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelOpJoinOuterFull.kt index 062d18234b..0ef786f2ab 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelOpJoinOuterFull.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelOpJoinOuterFull.kt @@ -24,8 +24,8 @@ internal class RelOpJoinOuterFull( ) : RelOpPeeking() { // TODO BETTER MECHANISM FOR NULL PADDING - private val r = rhsType.getFields().toTypedArray() - private val l = lhsType.getFields().toTypedArray() + private val r = rhsType.getFields() + private val l = lhsType.getFields() private val lhsPadded: Row = Row(l.indices.map { Datum.nullValue(l[it].type) }.toTypedArray()) private val rhsPadded: Row = diff --git a/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt b/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt index 912b578878..c165ba7a53 100644 --- a/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt +++ b/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt @@ -34,7 +34,7 @@ public class StrategyTest { var trigged = false val pattern = Pattern(RelLimit::class.java) val strategy = object : Strategy(pattern) { - override fun apply(match: Match): Expr { + override fun apply(match: Match, mode: Mode, callback: Callback): Expr { trigged = true return MyLimit() } diff --git a/partiql-plan/README.md b/partiql-plan/README.md new file mode 100644 index 0000000000..f884d58f57 --- /dev/null +++ b/partiql-plan/README.md @@ -0,0 +1,81 @@ +# partiql-plan + +This package holds logical plans which are composed of actions and operator trees. + +* Operator (tree node interface) +* Rel & RelBase +* Rex & RexBase +* OperatorVisitor +* OperatorRewriter + +## Operands + +What are operands? + +* Operands are an important concept +* An operand is an input to some operator. +* An operator may have more than one operand e.g. join (left and right). +* Rel operands are typically called "inputs" +* Operands unify inputs since PartiQL bridges rel/rex domains. +* Not all operators are operands e.g. the limit of RelLimit is a rex, but not an operand - it is an "arg" + +| Operator | Operands | Arguments | +|-----------------|------------------|------------------------| +| RelAggregate | input | measures, groups | +| RelCorrelate | left, right | joinType | +| RelDistinct | input | | +| RelExcept | left, right | all | +| RelExclude | input | exclusions | +| RelFilter | input | predicate | +| RelIntersect | left, right | all | +| RelIterate | rex | | +| RelJoin | left, right | joinType, condition | +| RelLimit | input | limit | +| RelOffset | input | offset | +| RelProject | input | projections | +| RelScan | rex | | +| RelSort | input | collations | +| RelUnion | left, right | all | +| RelUnpivot | rex | | +| RexArray | values (vararg) | | +| RexBag | values (vararg) | | +| RexCall | args | | +| RexCase | match (optional) | branches, default | +| RexCast | operand | type | +| RexCoalesce | args (vararg) | | +| RexDispatch | args (vararg) | | +| RexLit | | value | +| RexNullIf | v1, v2 | | +| RexPathIndex | operand | index | +| RexPathKey | operand | key | +| RexPathSymbol | operand | symbol | +| RexPivot | input | key, value | +| RexSelect | input | constructor | +| RexSpread | args (vararg) | | +| RexStruct | | fields | +| RexSubquery | input | | +| RexSubqueryComp | input | comparison, quantifier | +| RexSubqueryIn | input | args | +| RexSubqueryTest | input | test | +| RexTable | | table | +| RexVar | | scope, offset | + +## Design + +For the rule and strategy patterns to work, we need to model classes whose operands have a stable ordering; +so we have defined an abstract base class for all operators which holds operands and controls the access to them. +We use base implementations for state management and enforcing operands ordering; however we use interfaces for the +top-level of each domain. The abstract bases can be extended, and the operator/rel/rex interfaces can be implemented +directly. + +Why interfaces for top-level domain entities and not abstract base classes? + +* We don’t want to force materialization of operands (consider wrapping a serde class) +* We don’t want to force holding state (aka having to call super constructors) +* The operator/rel/rex should be flexible for extension and the interface is the most open-ended / non-prescriptive. + +Why abstract base classes for individual operators and not interfaces? + +* Enforce operands ordering is the primary reason; also can memoize operands. +* Hold state such as mutable tags and computed types. +* We want the standard operators to be prescriptive but not limiting. diff --git a/partiql-plan/api/partiql-plan.api b/partiql-plan/api/partiql-plan.api index 78f758078b..a670c05cea 100644 --- a/partiql-plan/api/partiql-plan.api +++ b/partiql-plan/api/partiql-plan.api @@ -1,31 +1,32 @@ -public abstract interface class org/partiql/plan/AggregateCall { - public abstract fun getAgg ()Lorg/partiql/spi/function/Aggregation; - public abstract fun getArgs ()Ljava/util/List; - public abstract fun isDistinct ()Z +public abstract interface class org/partiql/plan/Action { +} + +public abstract interface class org/partiql/plan/Action$Query : org/partiql/plan/Action { + public abstract fun getRex ()Lorg/partiql/plan/rex/Rex; } public abstract interface class org/partiql/plan/Collation { + public abstract fun getColumn ()Lorg/partiql/plan/rex/Rex; public abstract fun getNulls ()Lorg/partiql/plan/Collation$Nulls; public abstract fun getOrder ()Lorg/partiql/plan/Collation$Order; - public abstract fun getRex ()Lorg/partiql/plan/rex/Rex; } -public final class org/partiql/plan/Collation$Nulls : java/lang/Enum { - public static final field FIRST Lorg/partiql/plan/Collation$Nulls; - public static final field LAST Lorg/partiql/plan/Collation$Nulls; - public static final field OTHER Lorg/partiql/plan/Collation$Nulls; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/Collation$Nulls; - public static fun values ()[Lorg/partiql/plan/Collation$Nulls; +public final class org/partiql/plan/Collation$Nulls : org/partiql/spi/Enum { + public static final field FIRST I + public static final field LAST I + public static final field UNKNOWN I + public static fun FIRST ()Lorg/partiql/plan/Collation$Nulls; + public static fun LAST ()Lorg/partiql/plan/Collation$Nulls; + public fun toString ()Ljava/lang/String; } -public final class org/partiql/plan/Collation$Order : java/lang/Enum { - public static final field ASC Lorg/partiql/plan/Collation$Order; - public static final field DESC Lorg/partiql/plan/Collation$Order; - public static final field OTHER Lorg/partiql/plan/Collation$Order; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/Collation$Order; - public static fun values ()[Lorg/partiql/plan/Collation$Order; +public final class org/partiql/plan/Collation$Order : org/partiql/spi/Enum { + public static final field ASC I + public static final field DESC I + public static final field UNKNOWN I + public static fun ASC ()Lorg/partiql/plan/Collation$Order; + public static fun DESC ()Lorg/partiql/plan/Collation$Order; + public fun toString ()Ljava/lang/String; } public final class org/partiql/plan/Exclusion { @@ -111,992 +112,810 @@ public final class org/partiql/plan/Exclusion$StructWildcard : org/partiql/plan/ public fun toString ()Ljava/lang/String; } -public final class org/partiql/plan/JoinType : java/lang/Enum { - public static final field FULL Lorg/partiql/plan/JoinType; - public static final field INNER Lorg/partiql/plan/JoinType; - public static final field LEFT Lorg/partiql/plan/JoinType; - public static final field RIGHT Lorg/partiql/plan/JoinType; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/JoinType; - public static fun values ()[Lorg/partiql/plan/JoinType; +public class org/partiql/plan/JoinType : org/partiql/spi/Enum { + public static final field FULL I + public static final field INNER I + public static final field LEFT I + public static final field RIGHT I + public static final field UNKNOWN I + public static fun FULL ()Lorg/partiql/plan/JoinType; + public static fun INNER ()Lorg/partiql/plan/JoinType; + public static fun LEFT ()Lorg/partiql/plan/JoinType; + public static fun RIGHT ()Lorg/partiql/plan/JoinType; } -public abstract interface class org/partiql/plan/Operation { +public abstract interface class org/partiql/plan/Operand : java/lang/Iterable { + public static fun single (Lorg/partiql/plan/Operator;)Lorg/partiql/plan/Operand; + public static fun vararg (Ljava/util/List;)Lorg/partiql/plan/Operand; } -public abstract interface class org/partiql/plan/Operation$Query : org/partiql/plan/Operation { - public abstract fun getRex ()Lorg/partiql/plan/rex/Rex; - public abstract fun getType ()Lorg/partiql/plan/rex/RexType; +public class org/partiql/plan/Operand$Single : org/partiql/plan/Operand { + public final field operator Lorg/partiql/plan/Operator; + public fun iterator ()Ljava/util/Iterator; } -public final class org/partiql/plan/Operation$Query$DefaultImpls { - public static fun getType (Lorg/partiql/plan/Operation$Query;)Lorg/partiql/plan/rex/RexType; +public class org/partiql/plan/Operand$Variadic : org/partiql/plan/Operand { + public final field operators Ljava/util/List; + public fun iterator ()Ljava/util/Iterator; } public abstract interface class org/partiql/plan/Operator { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChild (I)V - public abstract fun getChildren ()Ljava/util/Collection; -} - -public final class org/partiql/plan/Operator$DefaultImpls { - public static fun getChild (Lorg/partiql/plan/Operator;I)V + public abstract fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun getOperand (I)Lorg/partiql/plan/Operand; + public abstract fun getOperands ()Ljava/util/List; + public abstract fun getTag ()I + public abstract fun setTag (I)V +} + +public abstract class org/partiql/plan/OperatorTransform : org/partiql/plan/OperatorVisitor { + public fun ()V + public fun (Lorg/partiql/plan/Operators;)V + public synthetic fun defaultReturn (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun defaultReturn (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun defaultVisit (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun defaultVisit (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun onError (Lorg/partiql/plan/Operator;Ljava/lang/Class;)Lorg/partiql/plan/Operator; + public final fun visit (Lorg/partiql/plan/Operator;Ljava/lang/Object;Ljava/lang/Class;)Lorg/partiql/plan/Operator; + public synthetic fun visitAggregate (Lorg/partiql/plan/rel/RelAggregate;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitAggregate (Lorg/partiql/plan/rel/RelAggregate;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun visitAggregateGroup (Lorg/partiql/plan/rex/Rex;Ljava/lang/Object;)Lorg/partiql/plan/rex/Rex; + public fun visitAggregateMeasure (Lorg/partiql/plan/rel/RelAggregate$Measure;Ljava/lang/Object;)Lorg/partiql/plan/rel/RelAggregate$Measure; + public final fun visitAll (Ljava/util/List;Ljava/lang/Object;Lorg/partiql/plan/OperatorTransform$Mapper;)Ljava/util/List; + public synthetic fun visitArray (Lorg/partiql/plan/rex/RexArray;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitArray (Lorg/partiql/plan/rex/RexArray;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitBag (Lorg/partiql/plan/rex/RexBag;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitBag (Lorg/partiql/plan/rex/RexBag;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitCall (Lorg/partiql/plan/rex/RexCall;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCall (Lorg/partiql/plan/rex/RexCall;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitCase (Lorg/partiql/plan/rex/RexCase;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCase (Lorg/partiql/plan/rex/RexCase;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun visitCaseBranch (Lorg/partiql/plan/rex/RexCase$Branch;Ljava/lang/Object;)Lorg/partiql/plan/rex/RexCase$Branch; + public synthetic fun visitCast (Lorg/partiql/plan/rex/RexCast;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCast (Lorg/partiql/plan/rex/RexCast;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitCoalesce (Lorg/partiql/plan/rex/RexCoalesce;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCoalesce (Lorg/partiql/plan/rex/RexCoalesce;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun visitCollation (Lorg/partiql/plan/Collation;Ljava/lang/Object;)Lorg/partiql/plan/Collation; + public synthetic fun visitCorrelate (Lorg/partiql/plan/rel/RelCorrelate;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCorrelate (Lorg/partiql/plan/rel/RelCorrelate;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitDispatch (Lorg/partiql/plan/rex/RexDispatch;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitDispatch (Lorg/partiql/plan/rex/RexDispatch;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitDistinct (Lorg/partiql/plan/rel/RelDistinct;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitDistinct (Lorg/partiql/plan/rel/RelDistinct;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitError (Lorg/partiql/plan/rex/RexError;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitError (Lorg/partiql/plan/rex/RexError;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitExcept (Lorg/partiql/plan/rel/RelExcept;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExcept (Lorg/partiql/plan/rel/RelExcept;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitExclude (Lorg/partiql/plan/rel/RelExclude;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExclude (Lorg/partiql/plan/rel/RelExclude;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun visitExclusions (Lorg/partiql/plan/Exclusion;Ljava/lang/Object;)Lorg/partiql/plan/Exclusion; + public synthetic fun visitFilter (Lorg/partiql/plan/rel/RelFilter;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitFilter (Lorg/partiql/plan/rel/RelFilter;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitIntersect (Lorg/partiql/plan/rel/RelIntersect;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitIntersect (Lorg/partiql/plan/rel/RelIntersect;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitIterate (Lorg/partiql/plan/rel/RelIterate;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitIterate (Lorg/partiql/plan/rel/RelIterate;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitJoin (Lorg/partiql/plan/rel/RelJoin;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitJoin (Lorg/partiql/plan/rel/RelJoin;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitLimit (Lorg/partiql/plan/rel/RelLimit;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitLimit (Lorg/partiql/plan/rel/RelLimit;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitLit (Lorg/partiql/plan/rex/RexLit;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitLit (Lorg/partiql/plan/rex/RexLit;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitNullIf (Lorg/partiql/plan/rex/RexNullIf;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitNullIf (Lorg/partiql/plan/rex/RexNullIf;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitOffset (Lorg/partiql/plan/rel/RelOffset;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitOffset (Lorg/partiql/plan/rel/RelOffset;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitPathIndex (Lorg/partiql/plan/rex/RexPathIndex;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPathIndex (Lorg/partiql/plan/rex/RexPathIndex;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitPathKey (Lorg/partiql/plan/rex/RexPathKey;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPathKey (Lorg/partiql/plan/rex/RexPathKey;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitPathSymbol (Lorg/partiql/plan/rex/RexPathSymbol;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPathSymbol (Lorg/partiql/plan/rex/RexPathSymbol;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitPivot (Lorg/partiql/plan/rex/RexPivot;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPivot (Lorg/partiql/plan/rex/RexPivot;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitProject (Lorg/partiql/plan/rel/RelProject;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitProject (Lorg/partiql/plan/rel/RelProject;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun visitProjection (Lorg/partiql/plan/rex/Rex;Ljava/lang/Object;)Lorg/partiql/plan/rex/Rex; + public final fun visitRel (Lorg/partiql/plan/rel/Rel;Ljava/lang/Object;)Lorg/partiql/plan/rel/Rel; + public final fun visitRex (Lorg/partiql/plan/rex/Rex;Ljava/lang/Object;)Lorg/partiql/plan/rex/Rex; + public synthetic fun visitScan (Lorg/partiql/plan/rel/RelScan;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitScan (Lorg/partiql/plan/rel/RelScan;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitSelect (Lorg/partiql/plan/rex/RexSelect;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSelect (Lorg/partiql/plan/rex/RexSelect;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitSort (Lorg/partiql/plan/rel/RelSort;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSort (Lorg/partiql/plan/rel/RelSort;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitSpread (Lorg/partiql/plan/rex/RexSpread;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSpread (Lorg/partiql/plan/rex/RexSpread;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitStruct (Lorg/partiql/plan/rex/RexStruct;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitStruct (Lorg/partiql/plan/rex/RexStruct;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public fun visitStructField (Lorg/partiql/plan/rex/RexStruct$Field;Ljava/lang/Object;)Lorg/partiql/plan/rex/RexStruct$Field; + public synthetic fun visitSubquery (Lorg/partiql/plan/rex/RexSubquery;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubquery (Lorg/partiql/plan/rex/RexSubquery;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitSubqueryComp (Lorg/partiql/plan/rex/RexSubqueryComp;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubqueryComp (Lorg/partiql/plan/rex/RexSubqueryComp;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitSubqueryIn (Lorg/partiql/plan/rex/RexSubqueryIn;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubqueryIn (Lorg/partiql/plan/rex/RexSubqueryIn;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitSubqueryTest (Lorg/partiql/plan/rex/RexSubqueryTest;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubqueryTest (Lorg/partiql/plan/rex/RexSubqueryTest;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitTable (Lorg/partiql/plan/rex/RexTable;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitTable (Lorg/partiql/plan/rex/RexTable;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitUnion (Lorg/partiql/plan/rel/RelUnion;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitUnion (Lorg/partiql/plan/rel/RelUnion;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitUnpivot (Lorg/partiql/plan/rel/RelUnpivot;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitUnpivot (Lorg/partiql/plan/rel/RelUnpivot;Ljava/lang/Object;)Lorg/partiql/plan/Operator; + public synthetic fun visitVar (Lorg/partiql/plan/rex/RexVar;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitVar (Lorg/partiql/plan/rex/RexVar;Ljava/lang/Object;)Lorg/partiql/plan/Operator; +} + +public abstract interface class org/partiql/plan/OperatorTransform$Mapper { + public abstract fun apply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class org/partiql/plan/OperatorVisitor { + public abstract fun defaultReturn (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun defaultVisit (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun visit (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitAggregate (Lorg/partiql/plan/rel/RelAggregate;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitArray (Lorg/partiql/plan/rex/RexArray;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitBag (Lorg/partiql/plan/rex/RexBag;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCall (Lorg/partiql/plan/rex/RexCall;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCase (Lorg/partiql/plan/rex/RexCase;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCast (Lorg/partiql/plan/rex/RexCast;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCoalesce (Lorg/partiql/plan/rex/RexCoalesce;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCorrelate (Lorg/partiql/plan/rel/RelCorrelate;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitDispatch (Lorg/partiql/plan/rex/RexDispatch;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitDistinct (Lorg/partiql/plan/rel/RelDistinct;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitError (Lorg/partiql/plan/rex/RexError;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExcept (Lorg/partiql/plan/rel/RelExcept;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExclude (Lorg/partiql/plan/rel/RelExclude;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitFilter (Lorg/partiql/plan/rel/RelFilter;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitIntersect (Lorg/partiql/plan/rel/RelIntersect;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitIterate (Lorg/partiql/plan/rel/RelIterate;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitJoin (Lorg/partiql/plan/rel/RelJoin;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitLimit (Lorg/partiql/plan/rel/RelLimit;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitLit (Lorg/partiql/plan/rex/RexLit;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitNullIf (Lorg/partiql/plan/rex/RexNullIf;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitOffset (Lorg/partiql/plan/rel/RelOffset;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPathIndex (Lorg/partiql/plan/rex/RexPathIndex;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPathKey (Lorg/partiql/plan/rex/RexPathKey;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPathSymbol (Lorg/partiql/plan/rex/RexPathSymbol;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitPivot (Lorg/partiql/plan/rex/RexPivot;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitProject (Lorg/partiql/plan/rel/RelProject;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitScan (Lorg/partiql/plan/rel/RelScan;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSelect (Lorg/partiql/plan/rex/RexSelect;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSort (Lorg/partiql/plan/rel/RelSort;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSpread (Lorg/partiql/plan/rex/RexSpread;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitStruct (Lorg/partiql/plan/rex/RexStruct;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubquery (Lorg/partiql/plan/rex/RexSubquery;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubqueryComp (Lorg/partiql/plan/rex/RexSubqueryComp;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubqueryIn (Lorg/partiql/plan/rex/RexSubqueryIn;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitSubqueryTest (Lorg/partiql/plan/rex/RexSubqueryTest;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitTable (Lorg/partiql/plan/rex/RexTable;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitUnion (Lorg/partiql/plan/rel/RelUnion;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitUnpivot (Lorg/partiql/plan/rel/RelUnpivot;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitVar (Lorg/partiql/plan/rex/RexVar;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class org/partiql/plan/Operators { + public static final field Companion Lorg/partiql/plan/Operators$Companion; + public static final field STANDARD Lorg/partiql/plan/Operators; + public abstract fun aggregate (Lorg/partiql/plan/rel/Rel;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate; + public abstract fun array (Ljava/util/List;)Lorg/partiql/plan/rex/RexArray; + public abstract fun bag (Ljava/util/Collection;)Lorg/partiql/plan/rex/RexBag; + public abstract fun call (Lorg/partiql/spi/function/Function$Instance;Ljava/util/List;)Lorg/partiql/plan/rex/RexCall; + public abstract fun caseWhen (Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; + public abstract fun cast (Lorg/partiql/plan/rex/Rex;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexCast; + public abstract fun coalesce (Ljava/util/List;)Lorg/partiql/plan/rex/RexCoalesce; + public abstract fun correlate (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelCorrelate; + public abstract fun dispatch (Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rex/RexDispatch; + public abstract fun distinct (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelDistinct; + public abstract fun error (Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexError; + public abstract fun except (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelExcept; + public abstract fun exclude (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelExclude; + public abstract fun filter (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelFilter; + public abstract fun intersect (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelIntersect; + public abstract fun iterate (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelIterate; + public abstract fun join (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelJoin; + public abstract fun limit (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelLimit; + public abstract fun lit (Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/rex/RexLit; + public abstract fun nullIf (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexNullIf; + public abstract fun offset (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelOffset; + public abstract fun pathIndex (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathIndex; + public abstract fun pathKey (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathKey; + public abstract fun pathSymbol (Lorg/partiql/plan/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/rex/RexPathSymbol; + public abstract fun pivot (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPivot; + public abstract fun project (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelProject; + public abstract fun scan (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelScan; + public abstract fun select (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexSelect; + public abstract fun sort (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelSort; + public abstract fun spread (Ljava/util/List;)Lorg/partiql/plan/rex/RexSpread; + public abstract fun struct (Ljava/util/List;)Lorg/partiql/plan/rex/RexStruct; + public abstract fun subquery (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Z)Lorg/partiql/plan/rex/RexSubquery; + public abstract fun subqueryComp (Lorg/partiql/plan/rel/Rel;Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comparison;Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier;)Lorg/partiql/plan/rex/RexSubqueryComp; + public abstract fun subqueryIn (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rex/RexSubqueryIn; + public abstract fun subqueryTest (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/RexSubqueryTest$Test;)Lorg/partiql/plan/rex/RexSubqueryTest; + public abstract fun table (Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/rex/RexTable; + public abstract fun union (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelUnion; + public abstract fun unpivot (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelUnpivot; + public abstract fun variable (IILorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexVar; +} + +public final class org/partiql/plan/Operators$Companion { +} + +public final class org/partiql/plan/Operators$DefaultImpls { + public static fun aggregate (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate; + public static fun array (Lorg/partiql/plan/Operators;Ljava/util/List;)Lorg/partiql/plan/rex/RexArray; + public static fun bag (Lorg/partiql/plan/Operators;Ljava/util/Collection;)Lorg/partiql/plan/rex/RexBag; + public static fun call (Lorg/partiql/plan/Operators;Lorg/partiql/spi/function/Function$Instance;Ljava/util/List;)Lorg/partiql/plan/rex/RexCall; + public static fun caseWhen (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; + public static fun cast (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexCast; + public static fun coalesce (Lorg/partiql/plan/Operators;Ljava/util/List;)Lorg/partiql/plan/rex/RexCoalesce; + public static fun correlate (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelCorrelate; + public static fun dispatch (Lorg/partiql/plan/Operators;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rex/RexDispatch; + public static fun distinct (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelDistinct; + public static fun error (Lorg/partiql/plan/Operators;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexError; + public static fun except (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelExcept; + public static fun exclude (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelExclude; + public static fun filter (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelFilter; + public static fun intersect (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelIntersect; + public static fun iterate (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelIterate; + public static fun join (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelJoin; + public static fun limit (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelLimit; + public static fun lit (Lorg/partiql/plan/Operators;Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/rex/RexLit; + public static fun nullIf (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexNullIf; + public static fun offset (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelOffset; + public static fun pathIndex (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathIndex; + public static fun pathKey (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathKey; + public static fun pathSymbol (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/rex/RexPathSymbol; + public static fun pivot (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPivot; + public static fun project (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelProject; + public static fun scan (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelScan; + public static fun select (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexSelect; + public static fun sort (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelSort; + public static fun spread (Lorg/partiql/plan/Operators;Ljava/util/List;)Lorg/partiql/plan/rex/RexSpread; + public static fun struct (Lorg/partiql/plan/Operators;Ljava/util/List;)Lorg/partiql/plan/rex/RexStruct; + public static fun subquery (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Z)Lorg/partiql/plan/rex/RexSubquery; + public static fun subqueryComp (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comparison;Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier;)Lorg/partiql/plan/rex/RexSubqueryComp; + public static fun subqueryIn (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rex/RexSubqueryIn; + public static fun subqueryTest (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/RexSubqueryTest$Test;)Lorg/partiql/plan/rex/RexSubqueryTest; + public static fun table (Lorg/partiql/plan/Operators;Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/rex/RexTable; + public static fun union (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelUnion; + public static fun unpivot (Lorg/partiql/plan/Operators;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelUnpivot; + public static fun variable (Lorg/partiql/plan/Operators;IILorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexVar; } public abstract interface class org/partiql/plan/Plan { - public abstract fun getOperation ()Lorg/partiql/plan/Operation; - public abstract fun getVersion ()Lorg/partiql/plan/Version; -} - -public final class org/partiql/plan/Plan$DefaultImpls { - public static fun getVersion (Lorg/partiql/plan/Plan;)Lorg/partiql/plan/Version; + public abstract fun getAction ()Lorg/partiql/plan/Action; + public fun getVersion ()Lorg/partiql/plan/Version; } -public abstract interface class org/partiql/plan/Version { - public abstract fun toString ()Ljava/lang/String; -} - -public abstract interface class org/partiql/plan/Visitor { - public abstract fun defaultReturn (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun defaultVisit (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visit (Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitAggregate (Lorg/partiql/plan/rel/RelAggregate;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitArray (Lorg/partiql/plan/rex/RexArray;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitBag (Lorg/partiql/plan/rex/RexBag;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitCall (Lorg/partiql/plan/rex/RexCall;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitCallDynamic (Lorg/partiql/plan/rex/RexCallDynamic;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitCase (Lorg/partiql/plan/rex/RexCase;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitCast (Lorg/partiql/plan/rex/RexCast;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitCoalesce (Lorg/partiql/plan/rex/RexCoalesce;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitCorrelate (Lorg/partiql/plan/rel/RelCorrelate;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitDistinct (Lorg/partiql/plan/rel/RelDistinct;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitError (Lorg/partiql/plan/rex/RexError;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitExcept (Lorg/partiql/plan/rel/RelExcept;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitExclude (Lorg/partiql/plan/rel/RelExclude;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitFilter (Lorg/partiql/plan/rel/RelFilter;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitIntersect (Lorg/partiql/plan/rel/RelIntersect;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitIterate (Lorg/partiql/plan/rel/RelIterate;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitJoin (Lorg/partiql/plan/rel/RelJoin;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitLimit (Lorg/partiql/plan/rel/RelLimit;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitLit (Lorg/partiql/plan/rex/RexLit;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitNullIf (Lorg/partiql/plan/rex/RexNullIf;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitOffset (Lorg/partiql/plan/rel/RelOffset;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPathIndex (Lorg/partiql/plan/rex/RexPathIndex;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPathKey (Lorg/partiql/plan/rex/RexPathKey;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPathSymbol (Lorg/partiql/plan/rex/RexPathSymbol;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPivot (Lorg/partiql/plan/rex/RexPivot;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitProject (Lorg/partiql/plan/rel/RelProject;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitScan (Lorg/partiql/plan/rel/RelScan;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSelect (Lorg/partiql/plan/rex/RexSelect;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSort (Lorg/partiql/plan/rel/RelSort;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSpread (Lorg/partiql/plan/rex/RexSpread;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitStruct (Lorg/partiql/plan/rex/RexStruct;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSubquery (Lorg/partiql/plan/rex/RexSubquery;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSubqueryComp (Lorg/partiql/plan/rex/RexSubqueryComp;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSubqueryIn (Lorg/partiql/plan/rex/RexSubqueryIn;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSubqueryTest (Lorg/partiql/plan/rex/RexSubqueryTest;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitTable (Lorg/partiql/plan/rex/RexTable;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitUnion (Lorg/partiql/plan/rel/RelUnion;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitUnpivot (Lorg/partiql/plan/rel/RelUnpivot;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitVar (Lorg/partiql/plan/rex/RexVar;Ljava/lang/Object;)Ljava/lang/Object; -} - -public final class org/partiql/plan/Visitor$DefaultImpls { - public static fun defaultVisit (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visit (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/Operator;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitAggregate (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelAggregate;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitArray (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexArray;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitBag (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexBag;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitCall (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexCall;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitCallDynamic (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexCallDynamic;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitCase (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexCase;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitCast (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexCast;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitCoalesce (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexCoalesce;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitCorrelate (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelCorrelate;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitDistinct (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelDistinct;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitError (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexError;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitExcept (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelExcept;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitExclude (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelExclude;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitFilter (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelFilter;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitIntersect (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelIntersect;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitIterate (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelIterate;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitJoin (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelJoin;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitLimit (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelLimit;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitLit (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexLit;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitNullIf (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexNullIf;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitOffset (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelOffset;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPathIndex (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexPathIndex;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPathKey (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexPathKey;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPathSymbol (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexPathSymbol;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPivot (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexPivot;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitProject (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelProject;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitScan (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelScan;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSelect (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexSelect;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSort (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelSort;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSpread (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexSpread;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitStruct (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexStruct;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSubquery (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexSubquery;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSubqueryComp (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexSubqueryComp;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSubqueryIn (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexSubqueryIn;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitSubqueryTest (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexSubqueryTest;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitTable (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexTable;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitUnion (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelUnion;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitUnpivot (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rel/RelUnpivot;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitVar (Lorg/partiql/plan/Visitor;Lorg/partiql/plan/rex/RexVar;Ljava/lang/Object;)Ljava/lang/Object; -} - -public abstract interface class org/partiql/plan/builder/PlanFactory { - public static final field Companion Lorg/partiql/plan/builder/PlanFactory$Companion; - public static fun getSTANDARD ()Lorg/partiql/plan/builder/PlanFactory; - public abstract fun relAggregate (Lorg/partiql/plan/rel/Rel;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate; - public abstract fun relAggregateCall (Lorg/partiql/spi/function/Aggregation;Ljava/util/List;Z)Lorg/partiql/plan/AggregateCall; - public abstract fun relCorrelate (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelCorrelate; - public abstract fun relCorrelate (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelCorrelate; - public abstract fun relDistinct (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelDistinct; - public abstract fun relExcept (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelExcept; - public abstract fun relExcept (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelExcept; - public abstract fun relExclude (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelExclude; - public abstract fun relFilter (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelFilter; - public abstract fun relIntersect (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelIntersect; - public abstract fun relIntersect (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelIntersect; - public abstract fun relIterate (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelIterate; - public abstract fun relJoin (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelJoin; - public abstract fun relJoin (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;Lorg/partiql/plan/rel/RelType;Lorg/partiql/plan/rel/RelType;)Lorg/partiql/plan/rel/RelJoin; - public abstract fun relLimit (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelLimit; - public abstract fun relOffset (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelOffset; - public abstract fun relProject (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelProject; - public abstract fun relScan (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelScan; - public abstract fun relSort (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelSort; - public abstract fun relUnion (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelUnion; - public abstract fun relUnion (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelUnion; - public abstract fun relUnpivot (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelUnpivot; - public abstract fun rexArray (Ljava/util/Collection;)Lorg/partiql/plan/rex/RexArray; - public abstract fun rexArray (Ljava/util/Collection;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexArray; - public abstract fun rexBag (Ljava/util/Collection;)Lorg/partiql/plan/rex/RexBag; - public abstract fun rexBag (Ljava/util/Collection;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexBag; - public abstract fun rexCall (Lorg/partiql/spi/function/Function$Instance;Ljava/util/List;)Lorg/partiql/plan/rex/RexCall; - public abstract fun rexCallDynamic (Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rex/RexCallDynamic; - public abstract fun rexCase (Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; - public abstract fun rexCase (Ljava/util/List;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexCase; - public abstract fun rexCase (Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; - public abstract fun rexCase (Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexCase; - public abstract fun rexCast (Lorg/partiql/plan/rex/Rex;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexCast; - public abstract fun rexCoalesce (Ljava/util/List;)Lorg/partiql/plan/rex/RexCoalesce; - public abstract fun rexCoalesce (Ljava/util/List;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexCoalesce; - public abstract fun rexError (Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexError; - public abstract fun rexLit (Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/rex/RexLit; - public abstract fun rexNullIf (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexNullIf; - public abstract fun rexPathIndex (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathIndex; - public abstract fun rexPathIndex (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexPathIndex; - public abstract fun rexPathKey (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathKey; - public abstract fun rexPathKey (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexPathKey; - public abstract fun rexPathSymbol (Lorg/partiql/plan/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/rex/RexPathSymbol; - public abstract fun rexPathSymbol (Lorg/partiql/plan/rex/Rex;Ljava/lang/String;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexPathSymbol; - public abstract fun rexPivot (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPivot; - public abstract fun rexSelect (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexSelect; - public abstract fun rexSpread (Ljava/util/List;)Lorg/partiql/plan/rex/RexSpread; - public abstract fun rexSpread (Ljava/util/List;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexSpread; - public abstract fun rexStruct (Ljava/util/List;)Lorg/partiql/plan/rex/RexStruct; - public abstract fun rexStruct (Ljava/util/List;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexStruct; - public abstract fun rexSubquery (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Z)Lorg/partiql/plan/rex/RexSubquery; - public abstract fun rexSubqueryComp (Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryComp; - public abstract fun rexSubqueryComp (Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryComp; - public abstract fun rexSubqueryIn (Ljava/util/List;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryIn; - public abstract fun rexSubqueryIn (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryIn; - public abstract fun rexSubqueryTest (Lorg/partiql/plan/rex/RexSubqueryTest$Test;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryTest; - public abstract fun rexTable (Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/rex/RexTable; - public abstract fun rexVar (II)Lorg/partiql/plan/rex/RexVar; - public abstract fun rexVar (IILorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexVar; -} - -public final class org/partiql/plan/builder/PlanFactory$Companion { - public final fun getSTANDARD ()Lorg/partiql/plan/builder/PlanFactory; -} - -public final class org/partiql/plan/builder/PlanFactory$DefaultImpls { - public static fun relAggregate (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate; - public static fun relAggregateCall (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/spi/function/Aggregation;Ljava/util/List;Z)Lorg/partiql/plan/AggregateCall; - public static synthetic fun relAggregateCall$default (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/spi/function/Aggregation;Ljava/util/List;ZILjava/lang/Object;)Lorg/partiql/plan/AggregateCall; - public static fun relCorrelate (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelCorrelate; - public static fun relCorrelate (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelCorrelate; - public static fun relDistinct (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelDistinct; - public static fun relExcept (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelExcept; - public static fun relExcept (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelExcept; - public static fun relExclude (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelExclude; - public static fun relFilter (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelFilter; - public static fun relIntersect (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelIntersect; - public static fun relIntersect (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelIntersect; - public static fun relIterate (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelIterate; - public static fun relJoin (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelJoin; - public static fun relJoin (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;Lorg/partiql/plan/rel/RelType;Lorg/partiql/plan/rel/RelType;)Lorg/partiql/plan/rel/RelJoin; - public static synthetic fun relJoin$default (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;Lorg/partiql/plan/rel/RelType;Lorg/partiql/plan/rel/RelType;ILjava/lang/Object;)Lorg/partiql/plan/rel/RelJoin; - public static fun relLimit (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelLimit; - public static fun relOffset (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelOffset; - public static fun relProject (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelProject; - public static fun relScan (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelScan; - public static fun relSort (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelSort; - public static fun relUnion (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelUnion; - public static fun relUnion (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelUnion; - public static fun relUnpivot (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelUnpivot; - public static fun rexArray (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/Collection;)Lorg/partiql/plan/rex/RexArray; - public static fun rexArray (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/Collection;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexArray; - public static fun rexBag (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/Collection;)Lorg/partiql/plan/rex/RexBag; - public static fun rexBag (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/Collection;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexBag; - public static fun rexCall (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/spi/function/Function$Instance;Ljava/util/List;)Lorg/partiql/plan/rex/RexCall; - public static fun rexCallDynamic (Lorg/partiql/plan/builder/PlanFactory;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rex/RexCallDynamic; - public static fun rexCase (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; - public static fun rexCase (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexCase; - public static fun rexCase (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; - public static fun rexCase (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexCase; - public static fun rexCast (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexCast; - public static fun rexCoalesce (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;)Lorg/partiql/plan/rex/RexCoalesce; - public static fun rexCoalesce (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexCoalesce; - public static fun rexError (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexError; - public static fun rexLit (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/rex/RexLit; - public static fun rexNullIf (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexNullIf; - public static fun rexPathIndex (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathIndex; - public static fun rexPathIndex (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexPathIndex; - public static fun rexPathKey (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathKey; - public static fun rexPathKey (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexPathKey; - public static fun rexPathSymbol (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/rex/RexPathSymbol; - public static fun rexPathSymbol (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Ljava/lang/String;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexPathSymbol; - public static fun rexPivot (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPivot; - public static fun rexSelect (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexSelect; - public static fun rexSpread (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;)Lorg/partiql/plan/rex/RexSpread; - public static fun rexSpread (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexSpread; - public static fun rexStruct (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;)Lorg/partiql/plan/rex/RexStruct; - public static fun rexStruct (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexStruct; - public static fun rexSubquery (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Z)Lorg/partiql/plan/rex/RexSubquery; - public static fun rexSubqueryComp (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryComp; - public static fun rexSubqueryComp (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryComp; - public static fun rexSubqueryIn (Lorg/partiql/plan/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryIn; - public static fun rexSubqueryIn (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryIn; - public static fun rexSubqueryTest (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/plan/rex/RexSubqueryTest$Test;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rex/RexSubqueryTest; - public static fun rexTable (Lorg/partiql/plan/builder/PlanFactory;Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/rex/RexTable; - public static fun rexVar (Lorg/partiql/plan/builder/PlanFactory;II)Lorg/partiql/plan/rex/RexVar; - public static fun rexVar (Lorg/partiql/plan/builder/PlanFactory;IILorg/partiql/plan/rex/RexType;)Lorg/partiql/plan/rex/RexVar; -} - -public final class org/partiql/plan/builder/RelBuilder { - public static final field Companion Lorg/partiql/plan/builder/RelBuilder$Companion; - public synthetic fun (Lorg/partiql/plan/builder/RelBuilder$Builder;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun aggregate (Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/builder/RelBuilder; - public final fun build ()Lorg/partiql/plan/rel/Rel; - public final fun build (Lorg/partiql/plan/builder/PlanFactory;)Lorg/partiql/plan/rel/Rel; - public final fun distinct ()Lorg/partiql/plan/builder/RelBuilder; - public final fun except (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/builder/RelBuilder; - public final fun exclude (Ljava/util/List;)Lorg/partiql/plan/builder/RelBuilder; - public final fun filter (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun intersect (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public static final fun iterate (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun join (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun join (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/builder/RelBuilder; - public final fun join (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun join (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/builder/RexBuilder;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/builder/RelBuilder; - public final fun limit (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun offset (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun pivot (Lorg/partiql/plan/builder/RexBuilder;Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun project (Ljava/util/List;)Lorg/partiql/plan/builder/RelBuilder; - public final fun project ([Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public static final fun scan (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun select (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun sort (Ljava/util/List;)Lorg/partiql/plan/builder/RelBuilder; - public final fun union (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/builder/RelBuilder; - public static final fun unpivot (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; -} - -public final class org/partiql/plan/builder/RelBuilder$Companion { - public final fun iterate (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun scan (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; - public final fun unpivot (Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RelBuilder; -} - -public final class org/partiql/plan/builder/RexBuilder { - public static final field Companion Lorg/partiql/plan/builder/RexBuilder$Companion; - public synthetic fun (Lorg/partiql/plan/builder/RexBuilder$Builder;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun array (Ljava/util/Collection;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun bag (Ljava/util/Collection;)Lorg/partiql/plan/builder/RexBuilder; - public final fun build ()Lorg/partiql/plan/rex/Rex; - public final fun build (Lorg/partiql/plan/builder/PlanFactory;)Lorg/partiql/plan/rex/Rex; - public final fun cast (Lorg/partiql/types/PType;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun coalesce (Ljava/util/List;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun exists (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun iterate ()Lorg/partiql/plan/builder/RelBuilder; - public static final fun lit (I)Lorg/partiql/plan/builder/RexBuilder; - public static final fun lit (J)Lorg/partiql/plan/builder/RexBuilder; - public static final fun lit (Ljava/lang/String;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun lit (Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun lit (Z)Lorg/partiql/plan/builder/RexBuilder; - public final fun path (I)Lorg/partiql/plan/builder/RexBuilder; - public final fun path (Ljava/lang/String;Z)Lorg/partiql/plan/builder/RexBuilder; - public static synthetic fun path$default (Lorg/partiql/plan/builder/RexBuilder;Ljava/lang/String;ZILjava/lang/Object;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun pivot (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/builder/RexBuilder;Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun scan ()Lorg/partiql/plan/builder/RelBuilder; - public static final fun select (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun spread (Ljava/util/List;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun struct (Ljava/util/List;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun subquery (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun table (Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/builder/RexBuilder; - public static final fun unique (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun unpivot ()Lorg/partiql/plan/builder/RelBuilder; - public static final fun variable (I)Lorg/partiql/plan/builder/RexBuilder; - public static final fun variable (II)Lorg/partiql/plan/builder/RexBuilder; -} - -public final class org/partiql/plan/builder/RexBuilder$Companion { - public final fun array (Ljava/util/Collection;)Lorg/partiql/plan/builder/RexBuilder; - public final fun bag (Ljava/util/Collection;)Lorg/partiql/plan/builder/RexBuilder; - public final fun coalesce (Ljava/util/List;)Lorg/partiql/plan/builder/RexBuilder; - public final fun exists (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun lit (I)Lorg/partiql/plan/builder/RexBuilder; - public final fun lit (J)Lorg/partiql/plan/builder/RexBuilder; - public final fun lit (Ljava/lang/String;)Lorg/partiql/plan/builder/RexBuilder; - public final fun lit (Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/builder/RexBuilder; - public final fun lit (Z)Lorg/partiql/plan/builder/RexBuilder; - public final fun pivot (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/builder/RexBuilder;Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun select (Lorg/partiql/plan/builder/RelBuilder;Lorg/partiql/plan/builder/RexBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun spread (Ljava/util/List;)Lorg/partiql/plan/builder/RexBuilder; - public final fun struct (Ljava/util/List;)Lorg/partiql/plan/builder/RexBuilder; - public final fun subquery (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun table (Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/builder/RexBuilder; - public final fun unique (Lorg/partiql/plan/builder/RelBuilder;)Lorg/partiql/plan/builder/RexBuilder; - public final fun variable (I)Lorg/partiql/plan/builder/RexBuilder; - public final fun variable (II)Lorg/partiql/plan/builder/RexBuilder; +public class org/partiql/plan/Version : org/partiql/spi/Enum { + public static final field UNKNOWN I + public static fun UNKNOWN ()Lorg/partiql/plan/Version; + public fun toString ()Ljava/lang/String; } public abstract interface class org/partiql/plan/rel/Rel : org/partiql/plan/Operator { public abstract fun getType ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z + public abstract fun setType (Lorg/partiql/plan/rel/RelType;)V } -public final class org/partiql/plan/rel/Rel$DefaultImpls { - public static fun getChild (Lorg/partiql/plan/rel/Rel;I)V -} - -public abstract interface class org/partiql/plan/rel/RelAggregate : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getCalls ()Ljava/util/List; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelAggregate : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelAggregate; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate; + public static fun create (Lorg/partiql/plan/rel/Rel;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate; public abstract fun getGroups ()Ljava/util/List; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelAggregate$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelAggregate;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelAggregate;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelAggregate;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelAggregate;)Z -} - -public abstract interface class org/partiql/plan/rel/RelCorrelate : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; + public abstract fun getMeasures ()Ljava/util/List; + public static fun measure (Lorg/partiql/spi/function/Aggregation;Ljava/util/List;Z)Lorg/partiql/plan/rel/RelAggregate$Measure; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; +} + +public class org/partiql/plan/rel/RelAggregate$Measure { + public fun copy (Ljava/util/List;)Lorg/partiql/plan/rel/RelAggregate$Measure; + public fun getAgg ()Lorg/partiql/spi/function/Aggregation; + public fun getArgs ()Ljava/util/List; + public fun isDistinct ()Z +} + +public abstract class org/partiql/plan/rel/RelBase : org/partiql/plan/rel/Rel { + public fun ()V + public final fun getOperand (I)Lorg/partiql/plan/Operand; + public final fun getOperands ()Ljava/util/List; + public fun getTag ()I + public final fun getType ()Lorg/partiql/plan/rel/RelType; + protected abstract fun operands ()Ljava/util/List; + public fun setTag (I)V + public fun setType (Lorg/partiql/plan/rel/RelType;)V + protected abstract fun type ()Lorg/partiql/plan/rel/RelType; +} + +public abstract class org/partiql/plan/rel/RelCorrelate : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelCorrelate; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelCorrelate; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelCorrelate; public abstract fun getJoinType ()Lorg/partiql/plan/JoinType; public abstract fun getLeft ()Lorg/partiql/plan/rel/Rel; public abstract fun getRight ()Lorg/partiql/plan/rel/Rel; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelCorrelate$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelCorrelate;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelCorrelate;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelCorrelate;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelCorrelate;)Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelDistinct : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelDistinct : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelDistinct; + public static fun create (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelDistinct; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; - public abstract fun getType ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelDistinct$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelDistinct;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelDistinct;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelDistinct;)Ljava/util/Collection; - public static fun getType (Lorg/partiql/plan/rel/RelDistinct;)Lorg/partiql/plan/rel/RelType; - public static fun isOrdered (Lorg/partiql/plan/rel/RelDistinct;)Z -} - -public abstract interface class org/partiql/plan/rel/RelExcept : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelExcept : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelExcept; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelExcept; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelExcept; public abstract fun getLeft ()Lorg/partiql/plan/rel/Rel; public abstract fun getRight ()Lorg/partiql/plan/rel/Rel; public abstract fun isAll ()Z - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelExcept$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelExcept;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelExcept;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelExcept;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelExcept;)Z -} - -public abstract interface class org/partiql/plan/rel/RelExclude : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelExclude : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelExclude; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelExclude; + public static fun create (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelExclude; public abstract fun getExclusions ()Ljava/util/List; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelExclude$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelExclude;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelExclude;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelExclude;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelExclude;)Z -} - -public abstract interface class org/partiql/plan/rel/RelFilter : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelFilter : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelFilter; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelFilter; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelFilter; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getPredicate ()Lorg/partiql/plan/rex/Rex; - public abstract fun getType ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelFilter$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelFilter;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelFilter;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelFilter;)Ljava/util/Collection; - public static fun getType (Lorg/partiql/plan/rel/RelFilter;)Lorg/partiql/plan/rel/RelType; - public static fun isOrdered (Lorg/partiql/plan/rel/RelFilter;)Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelIntersect : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelIntersect : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelIntersect; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelIntersect; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelIntersect; public abstract fun getLeft ()Lorg/partiql/plan/rel/Rel; public abstract fun getRight ()Lorg/partiql/plan/rel/Rel; public abstract fun isAll ()Z - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelIntersect$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelIntersect;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelIntersect;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelIntersect;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelIntersect;)Z -} - -public abstract interface class org/partiql/plan/rel/RelIterate : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getInput ()Lorg/partiql/plan/rex/Rex; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelIterate$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelIterate;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelIterate;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelIterate;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelIterate;)Z +public abstract class org/partiql/plan/rel/RelIterate : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelIterate; + public static fun create (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelIterate; + public abstract fun getRex ()Lorg/partiql/plan/rex/Rex; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelJoin : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelJoin : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelJoin; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelJoin; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/JoinType;)Lorg/partiql/plan/rel/RelJoin; public abstract fun getCondition ()Lorg/partiql/plan/rex/Rex; public abstract fun getJoinType ()Lorg/partiql/plan/JoinType; public abstract fun getLeft ()Lorg/partiql/plan/rel/Rel; - public abstract fun getLeftSchema ()Lorg/partiql/plan/rel/RelType; public abstract fun getRight ()Lorg/partiql/plan/rel/Rel; - public abstract fun getRightSchema ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelJoin$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelJoin;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelJoin;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelJoin;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelJoin;)Z -} - -public abstract interface class org/partiql/plan/rel/RelLimit : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelLimit : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelLimit; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelLimit; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelLimit; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getLimit ()Lorg/partiql/plan/rex/Rex; - public abstract fun getType ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelLimit$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelLimit;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelLimit;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelLimit;)Ljava/util/Collection; - public static fun getType (Lorg/partiql/plan/rel/RelLimit;)Lorg/partiql/plan/rel/RelType; - public static fun isOrdered (Lorg/partiql/plan/rel/RelLimit;)Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelOffset : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelOffset : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelOffset; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelOffset; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelOffset; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getOffset ()Lorg/partiql/plan/rex/Rex; - public abstract fun getType ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelOffset$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelOffset;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelOffset;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelOffset;)Ljava/util/Collection; - public static fun getType (Lorg/partiql/plan/rel/RelOffset;)Lorg/partiql/plan/rel/RelType; - public static fun isOrdered (Lorg/partiql/plan/rel/RelOffset;)Z -} - -public abstract interface class org/partiql/plan/rel/RelProject : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelProject : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelProject; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelProject; + public static fun create (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelProject; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getProjections ()Ljava/util/List; - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelProject$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelProject;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelProject;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelProject;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelProject;)Z -} - -public final class org/partiql/plan/rel/RelProjectImpl : org/partiql/plan/rel/RelProject { - public fun (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)V - public fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public fun equals (Ljava/lang/Object;)Z - public fun getChild (I)V - public fun getChildren ()Ljava/util/Collection; - public fun getInput ()Lorg/partiql/plan/rel/Rel; - public fun getProjections ()Ljava/util/List; - public fun getType ()Lorg/partiql/plan/rel/RelType; - public fun hashCode ()I - public fun isOrdered ()Z -} - -public abstract interface class org/partiql/plan/rel/RelScan : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getInput ()Lorg/partiql/plan/rex/Rex; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelScan$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelScan;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelScan;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelScan;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelScan;)Z +public abstract class org/partiql/plan/rel/RelScan : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelScan; + public static fun create (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelScan; + public abstract fun getRex ()Lorg/partiql/plan/rex/Rex; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelSort : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelSort : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelSort; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelSort; + public static fun create (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rel/RelSort; public abstract fun getCollations ()Ljava/util/List; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; - public abstract fun getType ()Lorg/partiql/plan/rel/RelType; - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelSort$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelSort;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelSort;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelSort;)Ljava/util/Collection; - public static fun getType (Lorg/partiql/plan/rel/RelSort;)Lorg/partiql/plan/rel/RelType; - public static fun isOrdered (Lorg/partiql/plan/rel/RelSort;)Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelType { - public abstract fun getField (Ljava/lang/String;)Lorg/partiql/types/Field; - public abstract fun getFields ()Ljava/util/List; - public abstract fun getSize ()I -} - -public final class org/partiql/plan/rel/RelType$DefaultImpls { - public static fun getSize (Lorg/partiql/plan/rel/RelType;)I +public final class org/partiql/plan/rel/RelType { + public static final field ORDERED I + public fun getDegree ()I + public fun getField (I)Lorg/partiql/types/Field; + public fun getField (Ljava/lang/String;)Lorg/partiql/types/Field; + public fun getFields ()[Lorg/partiql/types/Field; + public fun isOrdered ()Z + public static fun of ([Lorg/partiql/types/Field;)Lorg/partiql/plan/rel/RelType; + public static fun of ([Lorg/partiql/types/Field;I)Lorg/partiql/plan/rel/RelType; } -public abstract interface class org/partiql/plan/rel/RelUnion : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rel/RelUnion : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;)Lorg/partiql/plan/rel/RelUnion; + public abstract fun copy (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelUnion; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rel/Rel;Z)Lorg/partiql/plan/rel/RelUnion; public abstract fun getLeft ()Lorg/partiql/plan/rel/Rel; public abstract fun getRight ()Lorg/partiql/plan/rel/Rel; public abstract fun isAll ()Z - public abstract fun isOrdered ()Z -} - -public final class org/partiql/plan/rel/RelUnion$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelUnion;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelUnion;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelUnion;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelUnion;)Z -} - -public abstract interface class org/partiql/plan/rel/RelUnpivot : org/partiql/plan/rel/Rel { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getInput ()Lorg/partiql/plan/rex/Rex; - public abstract fun isOrdered ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } -public final class org/partiql/plan/rel/RelUnpivot$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rel/RelUnpivot;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rel/RelUnpivot;I)V - public static fun getChildren (Lorg/partiql/plan/rel/RelUnpivot;)Ljava/util/Collection; - public static fun isOrdered (Lorg/partiql/plan/rel/RelUnpivot;)Z +public abstract class org/partiql/plan/rel/RelUnpivot : org/partiql/plan/rel/RelBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun copy (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelUnpivot; + public static fun create (Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rel/RelUnpivot; + public abstract fun getRex ()Lorg/partiql/plan/rex/Rex; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rel/RelType; } public abstract interface class org/partiql/plan/rex/Rex : org/partiql/plan/Operator { public abstract fun getType ()Lorg/partiql/plan/rex/RexType; + public abstract fun setType (Lorg/partiql/plan/rex/RexType;)V } -public final class org/partiql/plan/rex/Rex$DefaultImpls { - public static fun getChild (Lorg/partiql/plan/rex/Rex;I)V +public abstract class org/partiql/plan/rex/RexArray : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Ljava/util/List;)Lorg/partiql/plan/rex/RexArray; + public abstract fun getValues ()Ljava/util/List; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexArray : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexBag : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Ljava/util/Collection;)Lorg/partiql/plan/rex/RexBag; public abstract fun getValues ()Ljava/util/Collection; -} - -public final class org/partiql/plan/rex/RexArray$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexArray;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexArray;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexArray;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexBag : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getValues ()Ljava/util/Collection; -} - -public final class org/partiql/plan/rex/RexBag$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexBag;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexBag;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexBag;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexCall : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; +} + +public abstract class org/partiql/plan/rex/RexBase : org/partiql/plan/rex/Rex { + public fun ()V + public final fun getOperand (I)Lorg/partiql/plan/Operand; + public final fun getOperands ()Ljava/util/List; + public fun getTag ()I + public final fun getType ()Lorg/partiql/plan/rex/RexType; + protected abstract fun operands ()Ljava/util/List; + public fun setTag (I)V + public final fun setType (Lorg/partiql/plan/rex/RexType;)V + protected abstract fun type ()Lorg/partiql/plan/rex/RexType; +} + +public abstract class org/partiql/plan/rex/RexCall : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/spi/function/Function$Instance;Ljava/util/List;)Lorg/partiql/plan/rex/RexCall; public abstract fun getArgs ()Ljava/util/List; - public abstract fun getChildren ()Ljava/util/Collection; public abstract fun getFunction ()Lorg/partiql/spi/function/Function$Instance; + protected fun operands ()Ljava/util/List; + protected fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexCall$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexCall;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexCall;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexCall;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexCallDynamic : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getArgs ()Ljava/util/List; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getFunctions ()Ljava/util/List; - public abstract fun getName ()Ljava/lang/String; -} - -public final class org/partiql/plan/rex/RexCallDynamic$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexCallDynamic;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexCallDynamic;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexCallDynamic;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexCase : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexCase : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun branch (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase$Branch; + public static fun create (Lorg/partiql/plan/rex/Rex;Ljava/util/List;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexCase; public abstract fun getBranches ()Ljava/util/List; - public abstract fun getChildren ()Ljava/util/Collection; public abstract fun getDefault ()Lorg/partiql/plan/rex/Rex; public abstract fun getMatch ()Lorg/partiql/plan/rex/Rex; + protected fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexCase$Branch { - public abstract fun getCondition ()Lorg/partiql/plan/rex/Rex; - public abstract fun getResult ()Lorg/partiql/plan/rex/Rex; -} - -public final class org/partiql/plan/rex/RexCase$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexCase;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexCase;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexCase;)Ljava/util/Collection; +public class org/partiql/plan/rex/RexCase$Branch { + public fun getCondition ()Lorg/partiql/plan/rex/Rex; + public fun getResult ()Lorg/partiql/plan/rex/Rex; } -public abstract interface class org/partiql/plan/rex/RexCast : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexCast : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rex/Rex;Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexCast; public abstract fun getOperand ()Lorg/partiql/plan/rex/Rex; public abstract fun getTarget ()Lorg/partiql/types/PType; + protected fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexCast$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexCast;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexCast;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexCast;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexCoalesce : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexCoalesce : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Ljava/util/List;)Lorg/partiql/plan/rex/RexCoalesce; public abstract fun getArgs ()Ljava/util/List; - public abstract fun getChildren ()Ljava/util/Collection; -} - -public final class org/partiql/plan/rex/RexCoalesce$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexCoalesce;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexCoalesce;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexCoalesce;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexError : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getType ()Lorg/partiql/plan/rex/RexType; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexError$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexError;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexError;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexError;)Ljava/util/Collection; - public static fun getType (Lorg/partiql/plan/rex/RexError;)Lorg/partiql/plan/rex/RexType; +public abstract class org/partiql/plan/rex/RexDispatch : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/rex/RexDispatch; + public abstract fun getArgs ()Ljava/util/List; + public abstract fun getFunctions ()Ljava/util/List; + public abstract fun getName ()Ljava/lang/String; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexLit : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getValue ()Lorg/partiql/spi/value/Datum; +public abstract class org/partiql/plan/rex/RexError : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create ()Lorg/partiql/plan/rex/RexError; + protected fun operands ()Ljava/util/List; + protected fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexLit$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexLit;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexLit;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexLit;)Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexLit : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/spi/value/Datum;)Lorg/partiql/plan/rex/RexLit; + public abstract fun getDatum ()Lorg/partiql/spi/value/Datum; + protected fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexNullIf : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexNullIf : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexNullIf; public abstract fun getV1 ()Lorg/partiql/plan/rex/Rex; public abstract fun getV2 ()Lorg/partiql/plan/rex/Rex; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexNullIf$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexNullIf;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexNullIf;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexNullIf;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexPathIndex : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexPathIndex : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathIndex; public abstract fun getIndex ()Lorg/partiql/plan/rex/Rex; public abstract fun getOperand ()Lorg/partiql/plan/rex/Rex; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexPathIndex$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexPathIndex;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexPathIndex;I)V -} - -public abstract interface class org/partiql/plan/rex/RexPathKey : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexPathKey : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPathKey; public abstract fun getKey ()Lorg/partiql/plan/rex/Rex; public abstract fun getOperand ()Lorg/partiql/plan/rex/Rex; + protected fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexPathKey$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexPathKey;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexPathKey;I)V -} - -public abstract interface class org/partiql/plan/rex/RexPathSymbol : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexPathSymbol : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/rex/RexPathSymbol; public abstract fun getOperand ()Lorg/partiql/plan/rex/Rex; public abstract fun getSymbol ()Ljava/lang/String; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexPathSymbol$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexPathSymbol;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexPathSymbol;I)V -} - -public abstract interface class org/partiql/plan/rex/RexPivot : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexPivot : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexPivot; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getKey ()Lorg/partiql/plan/rex/Rex; public abstract fun getValue ()Lorg/partiql/plan/rex/Rex; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexPivot$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexPivot;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexPivot;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexPivot;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexSelect : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexSelect : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexSelect; public abstract fun getConstructor ()Lorg/partiql/plan/rex/Rex; public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexSelect$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexSelect;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexSelect;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexSelect;)Ljava/util/Collection; -} - -public abstract interface class org/partiql/plan/rex/RexSpread : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexSpread : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Ljava/util/List;)Lorg/partiql/plan/rex/RexSpread; public abstract fun getArgs ()Ljava/util/List; - public abstract fun getChildren ()Ljava/util/Collection; -} - -public final class org/partiql/plan/rex/RexSpread$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexSpread;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexSpread;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexSpread;)Ljava/util/Collection; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexStruct : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexStruct : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Ljava/util/List;)Lorg/partiql/plan/rex/RexStruct; + public static fun field (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)Lorg/partiql/plan/rex/RexStruct$Field; public abstract fun getFields ()Ljava/util/List; + protected fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexStruct$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexStruct;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexStruct;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexStruct;)Ljava/util/Collection; +public class org/partiql/plan/rex/RexStruct$Field { + public fun getKey ()Lorg/partiql/plan/rex/Rex; + public fun getValue ()Lorg/partiql/plan/rex/Rex; } -public final class org/partiql/plan/rex/RexStruct$Field { - public fun (Lorg/partiql/plan/rex/Rex;Lorg/partiql/plan/rex/Rex;)V - public final fun getKey ()Lorg/partiql/plan/rex/Rex; - public final fun getValue ()Lorg/partiql/plan/rex/Rex; -} - -public abstract interface class org/partiql/plan/rex/RexSubquery : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun asScalar ()Z +public abstract class org/partiql/plan/rex/RexSubquery : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/Rex;Z)Lorg/partiql/plan/rex/RexSubquery; public abstract fun getConstructor ()Lorg/partiql/plan/rex/Rex; - public abstract fun getRel ()Lorg/partiql/plan/rel/Rel; -} - -public final class org/partiql/plan/rex/RexSubquery$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexSubquery;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexSubquery;I)V + public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; + public abstract fun isScalar ()Z + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexSubqueryComp : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; +public abstract class org/partiql/plan/rex/RexSubqueryComp : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rel/Rel;Ljava/util/List;Lorg/partiql/plan/rex/RexSubqueryComp$Comparison;Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier;)Lorg/partiql/plan/rex/RexSubqueryComp; public abstract fun getArgs ()Ljava/util/List; - public abstract fun getComp ()Lorg/partiql/plan/rex/RexSubqueryComp$Comp; + public abstract fun getComparison ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; + public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getQuantifier ()Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; - public abstract fun getRel ()Lorg/partiql/plan/rel/Rel; -} - -public final class org/partiql/plan/rex/RexSubqueryComp$Comp : java/lang/Enum { - public static final field EQ Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static final field GE Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static final field GT Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static final field LE Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static final field LT Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static final field NE Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static final field OTHER Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/rex/RexSubqueryComp$Comp; - public static fun values ()[Lorg/partiql/plan/rex/RexSubqueryComp$Comp; -} - -public final class org/partiql/plan/rex/RexSubqueryComp$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexSubqueryComp;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexSubqueryComp;I)V -} - -public final class org/partiql/plan/rex/RexSubqueryComp$Quantifier : java/lang/Enum { - public static final field ALL Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; - public static final field ANY Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; - public static final field OTHER Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; - public static final field SOME Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; - public static fun values ()[Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; -} - -public abstract interface class org/partiql/plan/rex/RexSubqueryIn : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; +} + +public class org/partiql/plan/rex/RexSubqueryComp$Comparison : org/partiql/spi/Enum { + public static final field EQ I + public static final field GE I + public static final field GT I + public static final field LE I + public static final field LT I + public static final field NE I + public static final field UNKNOWN I + public static fun EQ ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; + public static fun GE ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; + public static fun GT ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; + public static fun LE ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; + public static fun LT ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; + public static fun NE ()Lorg/partiql/plan/rex/RexSubqueryComp$Comparison; +} + +public class org/partiql/plan/rex/RexSubqueryComp$Quantifier : org/partiql/spi/Enum { + public static final field ALL I + public static final field ANY I + public static final field SOME I + public static final field UNKNOWN I + public static fun ALL ()Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; + public static fun ANY ()Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; + public static fun SOME ()Lorg/partiql/plan/rex/RexSubqueryComp$Quantifier; +} + +public abstract class org/partiql/plan/rex/RexSubqueryIn : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rel/Rel;Ljava/util/List;)Lorg/partiql/plan/rex/RexSubqueryIn; public abstract fun getArgs ()Ljava/util/List; - public abstract fun getRel ()Lorg/partiql/plan/rel/Rel; -} - -public final class org/partiql/plan/rex/RexSubqueryIn$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexSubqueryIn;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexSubqueryIn;I)V + public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public abstract interface class org/partiql/plan/rex/RexSubqueryTest : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getRel ()Lorg/partiql/plan/rel/Rel; +public abstract class org/partiql/plan/rex/RexSubqueryTest : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/plan/rel/Rel;Lorg/partiql/plan/rex/RexSubqueryTest$Test;)Lorg/partiql/plan/rex/RexSubqueryTest; + public abstract fun getInput ()Lorg/partiql/plan/rel/Rel; public abstract fun getTest ()Lorg/partiql/plan/rex/RexSubqueryTest$Test; + protected fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } -public final class org/partiql/plan/rex/RexSubqueryTest$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexSubqueryTest;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexSubqueryTest;I)V +public class org/partiql/plan/rex/RexSubqueryTest$Test : org/partiql/spi/Enum { + public static final field EXISTS I + public static final field UNIQUE I + public static final field UNKNOWN I + public static fun EXISTS ()Lorg/partiql/plan/rex/RexSubqueryTest$Test; + public static fun UNIQUE ()Lorg/partiql/plan/rex/RexSubqueryTest$Test; } -public final class org/partiql/plan/rex/RexSubqueryTest$Test : java/lang/Enum { - public static final field EXISTS Lorg/partiql/plan/rex/RexSubqueryTest$Test; - public static final field OTHER Lorg/partiql/plan/rex/RexSubqueryTest$Test; - public static final field UNIQUE Lorg/partiql/plan/rex/RexSubqueryTest$Test; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/rex/RexSubqueryTest$Test; - public static fun values ()[Lorg/partiql/plan/rex/RexSubqueryTest$Test; -} - -public abstract interface class org/partiql/plan/rex/RexTable : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; +public abstract class org/partiql/plan/rex/RexTable : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (Lorg/partiql/spi/catalog/Table;)Lorg/partiql/plan/rex/RexTable; public abstract fun getTable ()Lorg/partiql/spi/catalog/Table; -} - -public final class org/partiql/plan/rex/RexTable$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexTable;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexTable;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexTable;)Ljava/util/Collection; + protected final fun operands ()Ljava/util/List; + protected final fun type ()Lorg/partiql/plan/rex/RexType; } public final class org/partiql/plan/rex/RexType { - public static final field Companion Lorg/partiql/plan/rex/RexType$Companion; - public fun (Lorg/partiql/types/PType;)V - public static final fun dynamic ()Lorg/partiql/plan/rex/RexType; public fun equals (Ljava/lang/Object;)Z - public final fun getPType ()Lorg/partiql/types/PType; + public fun getPType ()Lorg/partiql/types/PType; public fun hashCode ()I + public static fun of (Lorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexType; public fun toString ()Ljava/lang/String; } -public final class org/partiql/plan/rex/RexType$Companion { - public final fun dynamic ()Lorg/partiql/plan/rex/RexType; -} - -public abstract interface class org/partiql/plan/rex/RexVar : org/partiql/plan/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getDepth ()I +public abstract class org/partiql/plan/rex/RexVar : org/partiql/plan/rex/RexBase { + public fun ()V + public fun accept (Lorg/partiql/plan/OperatorVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static fun create (IILorg/partiql/types/PType;)Lorg/partiql/plan/rex/RexVar; public abstract fun getOffset ()I -} - -public final class org/partiql/plan/rex/RexVar$DefaultImpls { - public static fun accept (Lorg/partiql/plan/rex/RexVar;Lorg/partiql/plan/Visitor;Ljava/lang/Object;)Ljava/lang/Object; - public static fun getChild (Lorg/partiql/plan/rex/RexVar;I)V - public static fun getChildren (Lorg/partiql/plan/rex/RexVar;)Ljava/util/Collection; + public abstract fun getScope ()I + protected final fun operands ()Ljava/util/List; } diff --git a/partiql-plan/build.gradle.kts b/partiql-plan/build.gradle.kts index d0c26e7032..2a22e3bd93 100644 --- a/partiql-plan/build.gradle.kts +++ b/partiql-plan/build.gradle.kts @@ -31,6 +31,14 @@ tasks.shadowJar { configurations = listOf(project.configurations.shadow.get()) } +tasks.withType { + enabled = false +} + +tasks.withType { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + // Workaround for https://github.com/johnrengelman/shadow/issues/651 components.withType(AdhocComponentWithVariants::class.java).forEach { c -> c.withVariantsFromConfiguration(project.configurations.shadowRuntimeElements.get()) { diff --git a/partiql-plan/src/main/java/org/partiql/plan/Action.java b/partiql-plan/src/main/java/org/partiql/plan/Action.java new file mode 100644 index 0000000000..4c6cdd2e16 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/Action.java @@ -0,0 +1,22 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.rex.Rex; + +/** + * A PartiQL statement action within a plan. + */ +public interface Action { + + /** + * PartiQL Query Statement — i.e. SELECT-FROM + */ + public interface Query extends Action { + + /** + * Returns the root expression of the query. + */ + @NotNull + public Rex getRex(); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/Collation.java b/partiql-plan/src/main/java/org/partiql/plan/Collation.java new file mode 100644 index 0000000000..f6330897c8 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/Collation.java @@ -0,0 +1,104 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.rex.Rex; +import org.partiql.spi.Enum; + +/** + * Represents a collation, which is a resolved sort specification. + */ +public interface Collation { + + /** + * API WARNING – THIS WILL BE REPLACED WITH AN `int` IN 1.0. + *
+ * TODO replace with an `int` in 1.0 + * + * @return the column to sort by + */ + public Rex getColumn(); + + /** + * @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 static final int UNKNOWN = 0; + public static final int ASC = 1; + public static final int DESC = 2; + + @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); + } + } + } + + /** + * 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 Nulls FIRST() { + return new Nulls(FIRST); + } + + @NotNull + public static Nulls LAST() { + return new Nulls(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/kotlin/org/partiql/plan/Exclusion.kt b/partiql-plan/src/main/java/org/partiql/plan/Exclusion.kt similarity index 96% rename from partiql-plan/src/main/kotlin/org/partiql/plan/Exclusion.kt rename to partiql-plan/src/main/java/org/partiql/plan/Exclusion.kt index 454c945274..0b9b91bbb0 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Exclusion.kt +++ b/partiql-plan/src/main/java/org/partiql/plan/Exclusion.kt @@ -34,18 +34,20 @@ public class Exclusion(variable: RexVar, items: List) { */ public fun getItems(): List = _items - // generated + /** + * UNSTABLE AND WILL BE DELETED (this only exists for unit tests) + */ override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is Exclusion) return false - - if (_variable != other._variable) return false + if (_variable.scope != other._variable.scope || _variable.offset != other._variable.offset) return false if (_items != other._items) return false - return true } - // generated + /** + * UNSTABLE AND WILL BE DELETED (this only exists for unit tests) + */ override fun hashCode(): Int { var result = _variable.hashCode() result = 31 * result + _items.hashCode() diff --git a/partiql-plan/src/main/java/org/partiql/plan/JoinType.java b/partiql-plan/src/main/java/org/partiql/plan/JoinType.java new file mode 100644 index 0000000000..76006de9e6 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/JoinType.java @@ -0,0 +1,40 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; +import org.partiql.spi.Enum; + +/** + * PartiQL JOIN types. + */ +public class JoinType extends Enum { + + public static final int UNKNOWN = 0; + public static final int INNER = 1; + public static final int LEFT = 2; + public static final int RIGHT = 3; + public static final int FULL = 4; + + private JoinType(int value) { + super(value); + } + + @NotNull + public static JoinType INNER() { + return new JoinType(INNER); + } + + @NotNull + public static JoinType LEFT() { + return new JoinType(LEFT); + } + + @NotNull + public static JoinType RIGHT() { + return new JoinType(RIGHT); + } + + @NotNull + public static JoinType FULL() { + return new JoinType(FULL); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/Operand.java b/partiql-plan/src/main/java/org/partiql/plan/Operand.java new file mode 100644 index 0000000000..4111eb62f4 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/Operand.java @@ -0,0 +1,68 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; + +import java.util.Iterator; +import java.util.List; + +/** + * Operands in an operator tree used for strategy and rule pattern matching. + */ +public interface Operand extends Iterable { + + /** + * @return a single operand + */ + public static Operand single(Operator operator) { + return new Single(operator); + } + + /** + * @return a variadic operand + * + * See ImmutableCollections.java ListCopy. + */ + @SuppressWarnings("unchecked") + public static Operand vararg(List operators) { + return new Variadic((List) operators); + } + + /** + * A single operator. + */ + public class Single implements Operand { + + @NotNull + public final Operator operator; + + private Single(@NotNull Operator operator) { + this.operator = operator; + } + + + @NotNull + @Override + public Iterator iterator() { + return List.of(operator).iterator(); + } + } + + /** + * A variadic operator. + */ + public class Variadic implements Operand { + + @NotNull + public final List operators; + + private Variadic(@NotNull List operators) { + this.operators = operators; + } + + @NotNull + @Override + public Iterator iterator() { + return operators.iterator(); + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/Operator.java b/partiql-plan/src/main/java/org/partiql/plan/Operator.java new file mode 100644 index 0000000000..17d9ec8cd4 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/Operator.java @@ -0,0 +1,45 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * The interface for all logical plan operators. + */ +public interface Operator { + + /** + * Tag getter. + */ + public int getTag(); + + /** + * Tag setter. + * + * @param tag new tag value. + */ + public void setTag(int tag); + + /** + * Visitor accept. + * + * @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(OperatorVisitor visitor, C ctx); + + /** + * @return the i-th operand + */ + public abstract Operand getOperand(int index); + + /** + * @return all input operands. + */ + @NotNull + public abstract List getOperands(); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/OperatorTransform.java b/partiql-plan/src/main/java/org/partiql/plan/OperatorTransform.java new file mode 100644 index 0000000000..ecf2e7cf45 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/OperatorTransform.java @@ -0,0 +1,695 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.rel.*; +import org.partiql.plan.rel.RelAggregate.Measure; +import org.partiql.plan.rex.*; +import org.partiql.plan.rex.RexCase.Branch; +import org.partiql.plan.rex.RexStruct.Field; + +import java.util.ArrayList; +import java.util.List; + +/** + * Operator transform is an abstract base visitor which recursively rewrites an operator tree. + */ +public abstract class OperatorTransform implements OperatorVisitor { + + /** + * Operator factory to use for rewrites. + */ + private final Operators operators; + + /** + * Base operator transform with standard operators factory. + */ + public OperatorTransform() { + this.operators = Operators.STANDARD; + } + + /** + * Base operator transform with custom operators factory. + */ + public OperatorTransform(Operators operators) { + this.operators = operators; + } + + @NotNull + @Override + public Operator defaultReturn(@NotNull Operator operator, C ctx) { + return operator; + } + + @NotNull + @Override + public Operator defaultVisit(Operator operator, C ctx) { + return operator; + } + + @NotNull + @Override + public Operator visitAggregate(@NotNull RelAggregate rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite measures + List measures = rel.getMeasures(); + List measures_new = visitAll(measures, ctx, this::visitAggregateMeasure); + // rewrite groups + List groups = rel.getGroups(); + List groups_new = visitAll(groups, ctx, this::visitAggregateGroup); + // rewrite aggregate + if (input != input_new || measures != measures_new || groups != groups_new) { + return operators.aggregate(input_new, measures_new, groups_new); + } + return rel; + } + + @NotNull + public Measure visitAggregateMeasure(@NotNull Measure measure, C ctx) { + // rewrite args + List args = measure.getArgs(); + List args_new = visitAll(args, ctx, this::visitAggregateGroup); + // rewrite aggregate measure + if (args != args_new) { + return measure.copy(args_new); + } + return measure; + } + + @NotNull + public Rex visitAggregateGroup(@NotNull Rex rex, C ctx) { + // rewrite aggregate group + return visit(rex, ctx, Rex.class); + } + + @Override + public Operator visitCorrelate(@NotNull RelCorrelate rel, C ctx) { + // rewrite left + Rel left = rel.getLeft(); + Rel left_new = visit(left, ctx, Rel.class); + // rewrite right + Rel right = rel.getRight(); + Rel right_new = visit(right, ctx, Rel.class); + // rewrite correlate + if (left != left_new || right != right_new) { + return operators.correlate(left_new, right_new, rel.getJoinType()); + } + return rel; + } + + @NotNull + @Override + public Operator visitDistinct(@NotNull RelDistinct rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite distinct + if (input != input_new) { + return operators.distinct(input_new); + } + return rel; + } + + @NotNull + @Override + public Operator visitExcept(@NotNull RelExcept rel, C ctx) { + // rewrite left + Rel left = rel.getLeft(); + Rel left_new = visit(left, ctx, Rel.class); + // rewrite right + Rel right = rel.getRight(); + Rel right_new = visit(right, ctx, Rel.class); + // rewrite except + if (left != left_new || right != right_new) { + return operators.except(left_new, right_new, rel.isAll()); + } + return rel; + } + + @NotNull + @Override + public Operator visitExclude(@NotNull RelExclude rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite exclusions + List exclusions = rel.getExclusions(); + List exclusions_new = visitAll(exclusions, ctx, this::visitExclusions); + // rewrite exclude + if (input != input_new) { + return operators.exclude(input_new, exclusions_new); + } + return rel; + } + + @NotNull + public Exclusion visitExclusions(@NotNull Exclusion exclusion, C ctx) { + // rewrite exclusion + return exclusion; + } + + @Override + public Operator visitFilter(@NotNull RelFilter rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite predicate + Rex predicate = rel.getPredicate(); + Rex predicate_new = visit(predicate, ctx, Rex.class); + // rewrite filter + if (input != input_new || predicate != predicate_new) { + return operators.filter(input_new, predicate_new); + } + return rel; + } + + @Override + public Operator visitIntersect(@NotNull RelIntersect rel, C ctx) { + // rewrite left + Rel left = rel.getLeft(); + Rel left_new = visit(left, ctx, Rel.class); + // rewrite right + Rel right = rel.getRight(); + Rel right_new = visit(right, ctx, Rel.class); + // rewrite intersect + if (left != left_new || right != right_new) { + return operators.intersect(left_new, right_new, rel.isAll()); + } + return rel; + } + + @Override + public Operator visitIterate(@NotNull RelIterate rel, C ctx) { + // rewrite rex + Rex rex = rel.getRex(); + Rex rex_new = visit(rex, ctx, Rex.class); + // rewrite iterate + if (rex != rex_new) { + return operators.iterate(rex_new); + } + return rel; + } + + @Override + public Operator visitJoin(@NotNull RelJoin rel, C ctx) { + // rewrite left + Rel left = rel.getLeft(); + Rel left_new = visit(left, ctx, Rel.class); + // rewrite right + Rel right = rel.getRight(); + Rel right_new = visit(right, ctx, Rel.class); + // rewrite condition + Rex condition = rel.getCondition(); + Rex condition_new = visit(condition, ctx, Rex.class); + // rewrite join + if (left != left_new || right != right_new || condition != condition_new) { + return operators.join(left_new, right_new, condition_new, rel.getJoinType()); + } + return rel; + } + + @Override + public Operator visitLimit(@NotNull RelLimit rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite limit + Rex limit = rel.getLimit(); + Rex limit_new = visit(limit, ctx, Rex.class); + // rewrite limit + if (input != input_new || limit != limit_new) { + return operators.limit(input_new, limit_new); + } + return rel; + } + + @Override + public Operator visitOffset(@NotNull RelOffset rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite offset + Rex offset = rel.getOffset(); + Rex offset_new = visit(offset, ctx, Rex.class); + // rewrite offset + if (input != input_new || offset != offset_new) { + return operators.offset(input_new, offset_new); + } + return rel; + } + + @Override + public Operator visitProject(@NotNull RelProject rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite projections + List projections = rel.getProjections(); + List projects_new = visitAll(projections, ctx, this::visitProjection); + // rewrite projection + if (input != input_new || projections != projects_new) { + return operators.project(input_new, projects_new); + } + return rel; + } + + @NotNull + public Rex visitProjection(@NotNull Rex rex, C ctx) { + // rewrite projection + return visit(rex, ctx, Rex.class); + } + + @Override + public Operator visitScan(@NotNull RelScan rel, C ctx) { + // rewrite rex + Rex rex = rel.getRex(); + Rex rex_new = visit(rex, ctx, Rex.class); + // rewrite scan + if (rex != rex_new) { + return operators.scan(rex_new); + } + return rel; + } + + @Override + public Operator visitSort(@NotNull RelSort rel, C ctx) { + // rewrite input + Rel input = rel.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite collations + List collations = rel.getCollations(); + List collations_new = visitAll(collations, ctx, this::visitCollation); + // rewrite sort + if (input != input_new || collations != collations_new) { + return operators.sort(input_new, collations_new); + } + return rel; + } + + @NotNull + public Collation visitCollation(@NotNull Collation collation, C ctx) { + // rewrite collation + return collation; + } + + @Override + public Operator visitUnion(@NotNull RelUnion rel, C ctx) { + // rewrite left + Rel left = rel.getLeft(); + Rel left_new = visit(left, ctx, Rel.class); + // rewrite right + Rel right = rel.getRight(); + Rel right_new = visit(right, ctx, Rel.class); + // rewrite union + if (left != left_new || right != right_new) { + return operators.union(left_new, right_new, rel.isAll()); + } + return rel; + } + + @Override + public Operator visitUnpivot(@NotNull RelUnpivot rel, C ctx) { + Rex rex = rel.getRex(); + Rex rex_new = visit(rex, ctx, Rex.class); + if (rex != rex_new) { + return operators.unpivot(rex); + } + return rel; + } + + @Override + public Operator visitArray(@NotNull RexArray rex, C ctx) { + // rewrite values + List values = rex.getValues(); + List values_new = visitAll(values, ctx, this::visitRex); + // rewrite array + if (values != values_new) { + return operators.array(values_new); + } + return rex; + } + + @Override + public Operator visitBag(@NotNull RexBag rex, C ctx) { + // rewrite values (necessarily ascribes order) + List values = List.copyOf(rex.getValues()); + List values_new = visitAll(values, ctx, this::visitRex); + // rewrite bag + if (values != values_new) { + return operators.bag(values_new); + } + return rex; + } + + @Override + public Operator visitCall(@NotNull RexCall rex, C ctx) { + // rewrite args + List args = rex.getArgs(); + List args_new = visitAll(args, ctx, this::visitRex); + // rewrite call + if (args != args_new) { + return operators.call(rex.getFunction(), args_new); + } + return rex; + } + + @Override + public Operator visitCase(@NotNull RexCase rex, C ctx) { + // rewrite match + Rex match = rex.getMatch(); + Rex match_new = (match != null) ? visit(match, ctx, Rex.class) : null; + // rewrite branches + List branches = rex.getBranches(); + List branches_new = visitAll(branches, ctx, this::visitCaseBranch); + // rewrite default + Rex default_ = rex.getDefault(); + Rex default_new = (default_ != null) ? visit(default_, ctx, Rex.class) : null; + // rewrite case + if (match != match_new || branches != branches_new || default_ != default_new) { + return operators.caseWhen(match_new, branches_new, default_new); + } + return rex; + } + + @NotNull + public Branch visitCaseBranch(@NotNull Branch branch, C ctx) { + // rewrite condition + Rex condition = branch.getCondition(); + Rex condition_new = visit(condition, ctx, Rex.class); + // rewrite result + Rex result = branch.getResult(); + Rex result_new = visit(result, ctx, Rex.class); + // rewrite branch + if (condition != condition_new || result != result_new) { + return RexCase.branch(condition_new, result_new); + } + return branch; + } + + @Override + public Operator visitCast(@NotNull RexCast rex, C ctx) { + // rewrite operand + Rex operand = rex.getOperand(); + Rex operand_new = visit(operand, ctx, Rex.class); + // rewrite cast + if (operand != operand_new) { + return operators.cast(operand_new, rex.getTarget()); + } + return rex; + } + + @Override + public Operator visitCoalesce(@NotNull RexCoalesce rex, C ctx) { + // rewrite args + List args = rex.getArgs(); + List args_new = visitAll(args, ctx, this::visitRex); + // rewrite coalesce + if (args != args_new) { + return operators.coalesce(args_new); + } + return rex; + } + + @Override + public Operator visitDispatch(@NotNull RexDispatch rex, C ctx) { + // rewrite args + List args = rex.getArgs(); + List args_new = visitAll(args, ctx, this::visitRex); + // rewrite dispatch + if (args != args_new) { + return operators.dispatch(rex.getName(), rex.getFunctions(), args_new); + } + return rex; + } + + @Override + public Operator visitError(@NotNull RexError rex, C ctx) { + return rex; + } + + @Override + public Operator visitLit(@NotNull RexLit rex, C ctx) { + return rex; + } + + @Override + public Operator visitNullIf(@NotNull RexNullIf rex, C ctx) { + // rewrite v1 + Rex v1 = rex.getV1(); + Rex v1_new = visit(v1, ctx, Rex.class); + // rewrite v2 + Rex v2 = rex.getV2(); + Rex v2_new = visit(v2, ctx, Rex.class); + // rewrite nullif + if (v1 != v1_new || v2 != v2_new) { + return operators.nullIf(v1_new, v2_new); + } + return rex; + } + + @Override + public Operator visitPathIndex(@NotNull RexPathIndex rex, C ctx) { + // rewrite operand + Rex operand = rex.getOperand(); + Rex operand_new = visit(operand, ctx, Rex.class); + // rewrite index + Rex index = rex.getIndex(); + Rex index_new = visit(index, ctx, Rex.class); + // rewrite path index + if (operand != operand_new || index != index_new) { + return operators.pathIndex(operand_new, index_new); + } + return rex; + } + + @Override + public Operator visitPathKey(@NotNull RexPathKey rex, C ctx) { + // rewrite operand + Rex operand = rex.getOperand(); + Rex operand_new = visit(operand, ctx, Rex.class); + // rewrite key + Rex key = rex.getKey(); + Rex key_new = visit(key, ctx, Rex.class); + // rewrite path key + if (operand != operand_new || key != key_new) { + return operators.pathKey(operand_new, key_new); + } + return rex; + } + + @Override + public Operator visitPathSymbol(@NotNull RexPathSymbol rex, C ctx) { + // rewrite operand + Rex operand = rex.getOperand(); + Rex operand_new = visit(operand, ctx, Rex.class); + // rewrite path symbol + if (operand != operand_new) { + return operators.pathSymbol(operand_new, rex.getSymbol()); + } + return rex; + } + + @Override + public Operator visitPivot(@NotNull RexPivot rex, C ctx) { + // rewrite input + Rel input = rex.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite key + Rex key = rex.getKey(); + Rex key_new = visit(key, ctx, Rex.class); + // rewrite value + Rex value = rex.getValue(); + Rex value_new = visit(value, ctx, Rex.class); + // rewrite pivot + if (input != input_new || key != key_new || value != value_new) { + return operators.pivot(input_new, key_new, value_new); + } + return rex; + } + + @Override + public Operator visitSelect(@NotNull RexSelect rex, C ctx) { + // rewrite input + Rel input = rex.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite constructor + Rex constructor = rex.getConstructor(); + Rex constructor_new = visit(constructor, ctx, Rex.class); + // rewrite select + if (input != input_new || constructor != constructor_new) { + return operators.select(input_new, constructor_new); + } + return rex; + } + + @Override + public Operator visitStruct(@NotNull RexStruct rex, C ctx) { + // rewrite fields + List fields = rex.getFields(); + List fields_new = visitAll(fields, ctx, this::visitStructField); + // rewrite struct + if (fields != fields_new) { + return operators.struct(fields_new); + } + return rex; + } + + @NotNull + public Field visitStructField(@NotNull Field field, C ctx) { + // rewrite key + Rex key = field.getKey(); + Rex key_new = visit(key, ctx, Rex.class); + // rewrite value + Rex value = field.getValue(); + Rex value_new = visit(value, ctx, Rex.class); + // rewrite field + if (key != key_new || value != value_new) { + return RexStruct.field(key_new, value_new); + } + return field; + } + + @Override + public Operator visitSubquery(@NotNull RexSubquery rex, C ctx) { + // rewrite input + Rel input = rex.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite constructor + Rex constructor = rex.getConstructor(); + Rex constructor_new = visit(constructor, ctx, Rex.class); + // rewrite subquery + if (input != input_new || constructor != constructor_new) { + return operators.subquery(input_new, constructor_new, rex.isScalar()); + } + return rex; + } + + @Override + public Operator visitSubqueryComp(@NotNull RexSubqueryComp rex, C ctx) { + // rewrite input + Rel input = rex.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite args + List args = rex.getArgs(); + List args_new = visitAll(args, ctx, this::visitRex); + // rewrite subquery comp + if (input != input_new) { + return operators.subqueryComp(input_new, args_new, rex.getComparison(), rex.getQuantifier()); + } + return rex; + } + + @Override + public Operator visitSubqueryIn(@NotNull RexSubqueryIn rex, C ctx) { + // rewrite input + Rel input = rex.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite args + List args = rex.getArgs(); + List args_new = visitAll(args, ctx, this::visitRex); + // rewrite subquery in + if (input != input_new) { + return operators.subqueryIn(input_new, args_new); + } + return rex; + } + + @Override + public Operator visitSubqueryTest(@NotNull RexSubqueryTest rex, C ctx) { + // rewrite input + Rel input = rex.getInput(); + Rel input_new = visit(input, ctx, Rel.class); + // rewrite subquery test + if (input != input_new) { + return operators.subqueryTest(input_new, rex.getTest()); + } + return rex; + } + + @Override + public Operator visitSpread(@NotNull RexSpread rex, C ctx) { + // rewrite args + List args = rex.getArgs(); + List args_new = visitAll(args, ctx, this::visitRex); + // rewrite spread + if (args != args_new) { + return operators.spread(args_new); + } + return rex; + } + + @Override + public Operator visitTable(@NotNull RexTable rex, C ctx) { + return rex; + } + + @Override + public Operator visitVar(@NotNull RexVar rex, C ctx) { + return rex; + } + + /** + * Helper method to visit a rel and cast as rel. + */ + @NotNull + public final Rel visitRel(@NotNull Rel rel, C ctx) { + return visit(rel, ctx, Rel.class); + } + + /** + * Helper method to visit a rex and cast as rex. + */ + @NotNull + public final Rex visitRex(@NotNull Rex rex, C ctx) { + return visit(rex, ctx, Rex.class); + } + + /** + * Helper method to visit an operator and cast to the expected type. + */ + @NotNull + public final T visit(@NotNull Operator operator, C ctx, Class clazz) { + Operator o = visit(operator, ctx); + if (clazz.isInstance(o)) { + return clazz.cast(o); + } + return onError(o, clazz); + } + + /** + * Helper method to visit a list of operators and return a new list if any operator was rewritten. + * Using this will drastically reduce rebuilds since a new list is created ONLY IF necessary. + * Doing .stream().map().collect() will always create a new list, even if no operators were rewritten. + */ + @NotNull + public final List visitAll(@NotNull List objects, C ctx, @NotNull Mapper mapper) { + if (objects.isEmpty()) { + return objects; + } + boolean diff = false; + List mapped = new ArrayList<>(objects.size()); + for (T o : objects) { + T t = mapper.apply(o, ctx); + mapped.add(t); + diff |= o != t; + } + return diff ? mapped : objects; + } + + /** + * Default error handling throws a ClassCastException. + */ + @NotNull + public T onError(@NotNull Operator o, @NotNull Class clazz) { + throw new ClassCastException("OperatorTransform expected " + clazz.getName() + ", found: " + o.getClass().getName()); + } + + /** + * @param + * @param + */ + public interface Mapper { + T apply(T op, C ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/OperatorVisitor.java b/partiql-plan/src/main/java/org/partiql/plan/OperatorVisitor.java new file mode 100644 index 0000000000..6b9198d636 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/OperatorVisitor.java @@ -0,0 +1,225 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.rel.RelAggregate; +import org.partiql.plan.rel.RelCorrelate; +import org.partiql.plan.rel.RelDistinct; +import org.partiql.plan.rel.RelExcept; +import org.partiql.plan.rel.RelExclude; +import org.partiql.plan.rel.RelFilter; +import org.partiql.plan.rel.RelIntersect; +import org.partiql.plan.rel.RelIterate; +import org.partiql.plan.rel.RelJoin; +import org.partiql.plan.rel.RelLimit; +import org.partiql.plan.rel.RelOffset; +import org.partiql.plan.rel.RelProject; +import org.partiql.plan.rel.RelScan; +import org.partiql.plan.rel.RelSort; +import org.partiql.plan.rel.RelUnion; +import org.partiql.plan.rel.RelUnpivot; +import org.partiql.plan.rex.RexArray; +import org.partiql.plan.rex.RexBag; +import org.partiql.plan.rex.RexCall; +import org.partiql.plan.rex.RexCase; +import org.partiql.plan.rex.RexCast; +import org.partiql.plan.rex.RexCoalesce; +import org.partiql.plan.rex.RexDispatch; +import org.partiql.plan.rex.RexError; +import org.partiql.plan.rex.RexLit; +import org.partiql.plan.rex.RexNullIf; +import org.partiql.plan.rex.RexPathIndex; +import org.partiql.plan.rex.RexPathKey; +import org.partiql.plan.rex.RexPathSymbol; +import org.partiql.plan.rex.RexPivot; +import org.partiql.plan.rex.RexSelect; +import org.partiql.plan.rex.RexSpread; +import org.partiql.plan.rex.RexStruct; +import org.partiql.plan.rex.RexSubquery; +import org.partiql.plan.rex.RexSubqueryComp; +import org.partiql.plan.rex.RexSubqueryIn; +import org.partiql.plan.rex.RexSubqueryTest; +import org.partiql.plan.rex.RexTable; +import org.partiql.plan.rex.RexVar; + +/** + * A visitor for a logical [Operator] tree. + * + * @param Visit return type + * @param Context parameter type + */ +public interface OperatorVisitor { + + default R defaultVisit(Operator operator, C ctx) { + for (Operand o : operator.getOperands()) { + for (Operator op : o) { + op.accept(this, ctx); + } + } + return defaultReturn(operator, ctx); + } + + R defaultReturn(@NotNull Operator operator, C ctx); + + default R visit(@NotNull Operator operator, C ctx) { + return operator.accept(this, ctx); + } + + // --[Rel]----------------------------------------------------------------------------------------------------------- + + default R visitAggregate(@NotNull RelAggregate rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitCorrelate(@NotNull RelCorrelate rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitDistinct(@NotNull RelDistinct rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitExcept(@NotNull RelExcept rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitExclude(@NotNull RelExclude rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitFilter(@NotNull RelFilter rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitIntersect(@NotNull RelIntersect rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitIterate(@NotNull RelIterate rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitJoin(@NotNull RelJoin rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitLimit(@NotNull RelLimit rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitOffset(@NotNull RelOffset rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitProject(@NotNull RelProject rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitScan(@NotNull RelScan rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitSort(@NotNull RelSort rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitUnion(@NotNull RelUnion rel, C ctx) { + return defaultVisit(rel, ctx); + } + + default R visitUnpivot(@NotNull RelUnpivot rel, C ctx) { + return defaultVisit(rel, ctx); + } + // --[Rex]----------------------------------------------------------------------------------------------------------- + + default R visitArray(@NotNull RexArray rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitBag(@NotNull RexBag rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitCall(@NotNull RexCall rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitCase(@NotNull RexCase rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitCast(@NotNull RexCast rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitCoalesce(@NotNull RexCoalesce rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitDispatch(@NotNull RexDispatch rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitError(@NotNull RexError rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitLit(@NotNull RexLit rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitNullIf(@NotNull RexNullIf rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitPathIndex(@NotNull RexPathIndex rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitPathKey(@NotNull RexPathKey rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitPathSymbol(@NotNull RexPathSymbol rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitPivot(@NotNull RexPivot rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitSelect(@NotNull RexSelect rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitStruct(@NotNull RexStruct rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitSubquery(@NotNull RexSubquery rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitSubqueryComp(@NotNull RexSubqueryComp rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitSubqueryIn(@NotNull RexSubqueryIn rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitSubqueryTest(@NotNull RexSubqueryTest rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitSpread(@NotNull RexSpread rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitTable(@NotNull RexTable rex, C ctx) { + return defaultVisit(rex, ctx); + } + + default R visitVar(@NotNull RexVar rex, C ctx) { + return defaultVisit(rex, ctx); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/Plan.java b/partiql-plan/src/main/java/org/partiql/plan/Plan.java new file mode 100644 index 0000000000..c4707803c8 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/Plan.java @@ -0,0 +1,23 @@ +package org.partiql.plan; + +import org.jetbrains.annotations.NotNull; + +/** + * A plan holds operations that can be executed. + */ +public interface Plan { + + /** + * @return version for serialization and debugging. + */ + @NotNull + default public Version getVersion() { + return Version.UNKNOWN(); + } + + /** + * @return statement action to execute. + */ + @NotNull + public Action getAction(); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/Version.java b/partiql-plan/src/main/java/org/partiql/plan/Version.java new file mode 100644 index 0000000000..e676506723 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/Version.java @@ -0,0 +1,29 @@ +package org.partiql.plan; + +import org.partiql.spi.Enum; + +/** + * A plan version. + */ +public class Version extends Enum { + + private Version(int code) { + super(code); + } + + public static final int UNKNOWN = 0; + + public static Version UNKNOWN() { + return new Version(UNKNOWN); + } + + @Override + public String toString() { + int code = code(); + switch (code) { + case UNKNOWN: + default: + return "UNKNOWN(" + code + ")"; + } + } +} 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 0000000000..73727d2e67 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java @@ -0,0 +1,21 @@ +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 the type of the rows produced by this rel. + */ + @NotNull + public RelType getType(); + + /** + * @param type the new type of the rows produced by this Rex. + */ + public void setType(@NotNull RelType type); +} 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 0000000000..f4320d9626 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelAggregate.java @@ -0,0 +1,164 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; +import org.partiql.spi.function.Aggregation; + +import java.util.List; + +// TODO GROUP STRATEGY: https://github.com/partiql/partiql-lang-kotlin/issues/1664 + +/** + * The logical aggregation abstract base class. + */ +public abstract class RelAggregate extends RelBase { + + /** + * @return new {@link RelAggregate} instance + */ + @NotNull + public static RelAggregate create(@NotNull Rel input, @NotNull List measures, @NotNull List groups) { + return new Impl(input, measures, groups); + } + + /** + * @return new {@link Measure} instance + */ + @NotNull + public static Measure measure(@NotNull Aggregation agg, @NotNull List args, @NotNull boolean distinct) { + return new Measure(agg, args, distinct); + } + + /** + * @return the input (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return the measures (arg) + */ + @NotNull + public abstract List getMeasures(); + + /** + * @return the groups (arg) + */ + @NotNull + public abstract List getGroups(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitAggregate(this, ctx); + } + + /** + * @return copy with new input. + */ + @NotNull + public abstract RelAggregate copy(@NotNull Rel input); + + /** + * @return copy with new input and args. + */ + @NotNull + public abstract RelAggregate copy(@NotNull Rel input, @NotNull List measures, @NotNull List groups); + + /** + * An aggregation function along with its arguments and any additional filters (e.g. DISTINCT). + *
+ * TODO unnest ?? + */ + public static class Measure { + + private final Aggregation agg; + private final List args; + private final boolean distinct; + + private Measure(Aggregation agg, List args, boolean distinct) { + this.agg = agg; + this.args = args; + this.distinct = distinct; + } + + @NotNull + public Aggregation getAgg() { + return agg; + } + + @NotNull + public List getArgs() { + return args; + } + + public boolean isDistinct() { + return distinct; + } + + @NotNull + public Measure copy(@NotNull List args) { + return new Measure(agg, args, distinct); + } + } + + private static class Impl extends RelAggregate { + + private final Rel input; + private final List measures; + private final List groups; + + private Impl(Rel input, List measures, List groups) { + this.input = input; + this.measures = measures; + this.groups = groups; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public List getMeasures() { + return measures; + } + + @NotNull + @Override + public List getGroups() { + return groups; + } + + @NotNull + @Override + public RelAggregate copy(@NotNull Rel input) { + return new Impl(input, measures, groups); + } + + /** + * @return copy with new input and args (non-final). + */ + @NotNull + @Override + public RelAggregate copy(@NotNull Rel input, @NotNull List measures, @NotNull List groups) { + return new Impl(input, measures, groups); + } + } +} 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 0000000000..6363a8b356 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelBase.java @@ -0,0 +1,74 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; + +import java.util.List; + +/** + * Abstract base class for all relational operators. + */ +public abstract class RelBase implements Rel { + + private int tag = 0; + private RelType type; + private List operands; + + @Override + public int getTag() { + return tag; + } + + @Override + public void setTag(int tag) { + this.tag = tag; + } + + @NotNull + @Override + public final RelType getType() { + if (type == null) { + type = type(); + } + return type; + } + + @Override + public void setType(@NotNull RelType type) { + this.type = type; + } + + @NotNull + @Override + public final Operand getOperand(int index) { + if (operands == null) { + operands = operands(); + } + return operands.get(index); + } + + @NotNull + @Override + public final List getOperands() { + if (operands == null) { + operands = operands(); + } + return operands; + } + + /** + * PROTECTED (could also be package private atm). + * + * @return computed type. + */ + @NotNull + protected abstract RelType type(); + + /** + * PROTECTED (could also be package private atm). + * + * @return computed operands. + */ + @NotNull + protected abstract List operands(); +} 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 0000000000..c9915b784b --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.java @@ -0,0 +1,108 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.JoinType; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical nested-loop joins (correlated subqueries, lateral joins, and cross joins) abstract base class. + *
+ *     l, r <=> l CROSS JOIN r <=> l JOIN r ON TRUE
+ * 
+ */ +public abstract class RelCorrelate extends RelBase { + + /** + * @return new {@link RelCorrelate} instance + */ + @NotNull + public static RelCorrelate create(@NotNull Rel left, @NotNull Rel right, @NotNull JoinType joinType) { + return new Impl(left, right, joinType); + } + + /** + * @return the left input (operand 0) + */ + @NotNull + public abstract Rel getLeft(); + + /** + * @return the right input (operand 1) + */ + @NotNull + public abstract Rel getRight(); + + @NotNull + public abstract JoinType getJoinType(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getLeft()); + Operand c1 = Operand.single(getRight()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitCorrelate(this, ctx); + } + + @NotNull + public abstract RelCorrelate copy(@NotNull Rel left, @NotNull Rel right); + + @NotNull + public abstract RelCorrelate copy(@NotNull Rel left, @NotNull Rel right, @NotNull JoinType joinType); + + private static class Impl extends RelCorrelate { + + private final Rel left; + private final Rel right; + private final JoinType joinType; + + private Impl(Rel left, Rel right, JoinType joinType) { + this.left = left; + this.right = right; + this.joinType = joinType; + } + + @NotNull + @Override + public Rel getLeft() { + return left; + } + + @NotNull + @Override + public Rel getRight() { + return right; + } + + @NotNull + @Override + public JoinType getJoinType() { + return joinType; + } + + @NotNull + @Override + public RelCorrelate copy(@NotNull Rel left, @NotNull Rel right) { + return new Impl(left, right, joinType); + } + + @NotNull + @Override + public RelCorrelate copy(@NotNull Rel left, @NotNull Rel right, @NotNull JoinType joinType) { + return new Impl(left, right, joinType); + } + } +} 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 0000000000..aa61ecbe35 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelDistinct.java @@ -0,0 +1,75 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical distinct operator abstract base class. + */ +public abstract class RelDistinct extends RelBase { + + /** + * @return new {@link RelDistinct} instance + */ + @NotNull + public static RelDistinct create(@NotNull Rel input) { + return new Impl(input); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitDistinct(this, ctx); + } + + /** + * @return copy with new input. + */ + @NotNull + public abstract RelDistinct copy(@NotNull Rel input); + + private static class Impl extends RelDistinct { + + private final Rel input; + + private Impl(Rel input) { + this.input = input; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + /** + * @return copy with new input (non-final). + */ + @NotNull + @Override + public RelDistinct copy(@NotNull Rel input) { + return create(input); + } + } +} 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 0000000000..690919e57a --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExcept.java @@ -0,0 +1,117 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical except abstract base class. + */ +public abstract class RelExcept extends RelBase { + + /** + * @return new {@link RelExcept} instance + */ + @NotNull + public static RelExcept create(@NotNull Rel left, @NotNull Rel right, boolean all) { + return new Impl(left, right, all); + } + + /** + * @return left input (operand 0) + */ + @NotNull + public abstract Rel getLeft(); + + /** + * @return right input (operand 1) + */ + @NotNull + public abstract Rel getRight(); + + /** + * @return true if ALL else DISTINCT. + */ + public abstract boolean isAll(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getLeft()); + Operand c1 = Operand.single(getRight()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitExcept(this, ctx); + } + + /** + * @return copy with new inputs (non-final). + */ + @NotNull + public abstract RelExcept copy(@NotNull Rel left, @NotNull Rel right); + + /** + * @return copy with new inputs and args (non-final). + */ + @NotNull + public abstract RelExcept copy(@NotNull Rel left, @NotNull Rel right, boolean all); + + private static class Impl extends RelExcept { + + private final Rel left; + private final Rel right; + private final boolean all; + + private Impl(Rel left, Rel right, boolean all) { + this.left = left; + this.right = right; + this.all = all; + } + + @NotNull + @Override + public Rel getLeft() { + return left; + } + + @NotNull + @Override + public Rel getRight() { + return right; + } + + @Override + public boolean isAll() { + return all; + } + + /** + * @return copy with new inputs (non-final). + */ + @NotNull + @Override + public RelExcept copy(@NotNull Rel left, @NotNull Rel right) { + return new Impl(left, right, all); + } + + /** + * @return copy with new inputs and args (non-final). + */ + @NotNull + @Override + public RelExcept copy(@NotNull Rel left, @NotNull Rel right, boolean all) { + return new Impl(left, right, all); + } + } +} 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 0000000000..5132dde914 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelExclude.java @@ -0,0 +1,93 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Exclusion; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical exclude abstract base class. + */ +public abstract class RelExclude extends RelBase { + + /** + * @return new {@link RelExclude} instance + */ + @NotNull + public static RelExclude create(@NotNull Rel input, @NotNull List exclusions) { + return new Impl(input, exclusions); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return exclusions (not an operator operand). + */ + @NotNull + public abstract List getExclusions(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitExclude(this, ctx); + } + + @NotNull + public abstract RelExclude copy(@NotNull Rel input); + + @NotNull + public abstract RelExclude copy(@NotNull Rel input, @NotNull List exclusions); + + private static class Impl extends RelExclude { + + private final Rel input; + private final List exclusions; + + private Impl(Rel input, List exclusions) { + this.input = input; + this.exclusions = exclusions; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public List getExclusions() { + return exclusions; + } + + @NotNull + @Override + public RelExclude copy(@NotNull Rel input) { + return new Impl(input, exclusions); + } + + @NotNull + @Override + public RelExclude copy(@NotNull Rel input, @NotNull List exclusions) { + return new Impl(input, exclusions); + } + } +} 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 0000000000..81e9365151 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelFilter.java @@ -0,0 +1,93 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical filter abstract base class. + */ +public abstract class RelFilter extends RelBase { + + /** + * @return new {@link RelFilter} instance + */ + @NotNull + public static RelFilter create(@NotNull Rel input, @NotNull Rex predicate) { + return new Impl(input, predicate); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return predicate rex. + */ + @NotNull + public abstract Rex getPredicate(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitFilter(this, ctx); + } + + @NotNull + public abstract RelFilter copy(@NotNull Rel input); + + @NotNull + public abstract RelFilter copy(@NotNull Rel input, @NotNull Rex predicate); + + private static class Impl extends RelFilter { + + private final Rel input; + private final Rex predicate; + + private Impl(Rel input, Rex predicate) { + this.input = input; + this.predicate = predicate; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Rex getPredicate() { + return predicate; + } + + @NotNull + @Override + public RelFilter copy(@NotNull Rel input) { + return new Impl(input, predicate); + } + + @NotNull + @Override + public RelFilter copy(@NotNull Rel input, @NotNull Rex predicate) { + return new Impl(input, predicate); + } + } +} 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 0000000000..6b0873ada9 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIntersect.java @@ -0,0 +1,105 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical intersect abstract base class. + */ +public abstract class RelIntersect extends RelBase { + + /** + * @return new {@link RelIntersect} instance + */ + @NotNull + public static RelIntersect create(@NotNull Rel left, @NotNull Rel right, boolean all) { + return new Impl(left, right, all); + } + + /** + * @return left rel (operand 0) + */ + @NotNull + public abstract Rel getLeft(); + + /** + * @return right rel (operand 1) + */ + @NotNull + public abstract Rel getRight(); + + /** + * @return true if ALL else DISTINCT. + */ + public abstract boolean isAll(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getLeft()); + Operand c1 = Operand.single(getRight()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitIntersect(this, ctx); + } + + @NotNull + public abstract RelIntersect copy(@NotNull Rel left, @NotNull Rel right); + + @NotNull + public abstract RelIntersect copy(@NotNull Rel left, @NotNull Rel right, boolean all); + + private static class Impl extends RelIntersect { + + private final Rel left; + private final Rel right; + private final boolean all; + + private Impl(Rel left, Rel right, boolean all) { + this.left = left; + this.right = right; + this.all = all; + } + + @NotNull + @Override + public Rel getLeft() { + return left; + } + + @NotNull + @Override + public Rel getRight() { + return right; + } + + @Override + public boolean isAll() { + return all; + } + + @NotNull + @Override + public RelIntersect copy(@NotNull Rel left, @NotNull Rel right) { + return new Impl(left, right, all); + } + + @NotNull + @Override + public RelIntersect copy(@NotNull Rel left, @NotNull Rel right, boolean all) { + return new Impl(left, right, all); + } + } +} 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 0000000000..ec449f7e9a --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelIterate.java @@ -0,0 +1,70 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical scan corresponding to the clause `FROM AS AT `. + */ +public abstract class RelIterate extends RelBase { + + /** + * @return new {@link RelIterate} instance + */ + @NotNull + public static RelIterate create(@NotNull Rex rex) { + return new Impl(rex); + } + + /** + * @return input rex (operand 0) + */ + @NotNull + public abstract Rex getRex(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getRex()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitIterate(this, ctx); + } + + @NotNull + public abstract RelIterate copy(@NotNull Rex rex); + + private static class Impl extends RelIterate { + + private final Rex rex; + + private Impl(Rex rex) { + this.rex = rex; + } + + @NotNull + @Override + public Rex getRex() { + return rex; + } + + @NotNull + @Override + public RelIterate copy(@NotNull Rex rex) { + return new Impl(rex); + } + } +} 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 0000000000..4b82888b5f --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelJoin.java @@ -0,0 +1,123 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.JoinType; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical theta-join abstract base class. + */ +public abstract class RelJoin extends RelBase { + + /** + * @return new {@link RelJoin} instance + */ + @NotNull + public static RelJoin create(@NotNull Rel left, @NotNull Rel right, @NotNull Rex condition, @NotNull JoinType joinType) { + return new Impl(left, right, condition, joinType); + } + + /** + * @return left input (operand 0) + */ + @NotNull + public abstract Rel getLeft(); + + /** + * @return right input (operand 1) + */ + @NotNull + public abstract Rel getRight(); + + /** + * @return JoinType + */ + @NotNull + public abstract JoinType getJoinType(); + + /** + * @return the join condition. + */ + @NotNull + public abstract Rex getCondition(); + + @NotNull + @Override + protected RelType type() { + throw new UnsupportedOperationException("compute join type"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getLeft()); + Operand c1 = Operand.single(getRight()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitJoin(this, ctx); + } + + @NotNull + public abstract RelJoin copy(@NotNull Rel left, @NotNull Rel right); + + @NotNull + public abstract RelJoin copy(@NotNull Rel left, @NotNull Rel right, @NotNull Rex condition, @NotNull JoinType joinType); + + private static class Impl extends RelJoin { + + private final Rel left; + private final Rel right; + private final Rex condition; + private final JoinType joinType; + + private Impl(Rel left, Rel right, Rex condition, JoinType joinType) { + this.left = left; + this.right = right; + this.condition = condition; + this.joinType = joinType; + } + + @NotNull + @Override + public Rel getLeft() { + return left; + } + + @NotNull + @Override + public Rel getRight() { + return right; + } + + @NotNull + @Override + public Rex getCondition() { + return condition; + } + + @NotNull + @Override + public JoinType getJoinType() { + return joinType; + } + + @NotNull + @Override + public RelJoin copy(@NotNull Rel left, @NotNull Rel right) { + return new Impl(left, right, condition, joinType); + } + + @NotNull + @Override + public RelJoin copy(@NotNull Rel left, @NotNull Rel right, @NotNull Rex condition, @NotNull JoinType joinType) { + return new Impl(left, right, condition, joinType); + } + } +} 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 0000000000..69b19e603b --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelLimit.java @@ -0,0 +1,94 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical limit abstract base class. + */ +public abstract class RelLimit extends RelBase { + + /** + * @return new {@link RelLimit} instance + */ + @NotNull + public static RelLimit create(@NotNull Rel input, @NotNull Rex limit) { + return new Impl(input, limit); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return limit rex (operand 1) + */ + @NotNull + public abstract Rex getLimit(); + + @NotNull + @Override + protected final RelType type() { + return getInput().getType(); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + Operand c1 = Operand.single(getLimit()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitLimit(this, ctx); + } + + @NotNull + public abstract RelLimit copy(@NotNull Rel input); + + @NotNull + public abstract RelLimit copy(@NotNull Rel input, @NotNull Rex limit); + + private static class Impl extends RelLimit { + + private final Rel input; + private final Rex limit; + + private Impl(Rel input, Rex limit) { + this.input = input; + this.limit = limit; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Rex getLimit() { + return limit; + } + + @NotNull + @Override + public RelLimit copy(@NotNull Rel input) { + return new Impl(input, limit); + } + + @NotNull + @Override + public RelLimit copy(@NotNull Rel input, @NotNull Rex limit) { + return new Impl(input, limit); + } + } +} 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 0000000000..01d9488754 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelOffset.java @@ -0,0 +1,94 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical offset abstract base class. + */ +public abstract class RelOffset extends RelBase { + + /** + * @return new {@link RelOffset} instance + */ + @NotNull + public static RelOffset create(@NotNull Rel input, @NotNull Rex offset) { + return new Impl(input, offset); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return offset rex (operand 1) + */ + @NotNull + public abstract Rex getOffset(); + + @NotNull + @Override + protected final RelType type() { + return getInput().getType(); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + Operand c1 = Operand.single(getOffset()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitOffset(this, ctx); + } + + @NotNull + public abstract RelOffset copy(@NotNull Rel input); + + @NotNull + public abstract RelOffset copy(@NotNull Rel input, @NotNull Rex offset); + + private static class Impl extends RelOffset { + + private final Rel input; + private final Rex offset; + + private Impl(Rel input, Rex offset) { + this.input = input; + this.offset = offset; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Rex getOffset() { + return offset; + } + + @NotNull + @Override + public RelOffset copy(@NotNull Rel input) { + return new Impl(input, offset); + } + + @NotNull + @Override + public RelOffset copy(@NotNull Rel input, @NotNull Rex offset) { + return new Impl(input, offset); + } + } +} 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 0000000000..13a587e2bd --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelProject.java @@ -0,0 +1,93 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical project abstract base class. + */ +public abstract class RelProject extends RelBase { + + /** + * @return new {@link RelProject} instance + */ + @NotNull + public static RelProject create(Rel input, List projections) { + return new Impl(input, projections); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return projection (not a operand, it's a list not an operator). + */ + @NotNull + public abstract List getProjections(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitProject(this, ctx); + } + + @NotNull + public abstract RelProject copy(@NotNull Rel input); + + @NotNull + public abstract RelProject copy(@NotNull Rel input, @NotNull List projections); + + private static class Impl extends RelProject { + + private final Rel input; + private final List projections; + + private Impl(Rel input, List projections) { + this.input = input; + this.projections = projections; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public List getProjections() { + return projections; + } + + @NotNull + @Override + public RelProject copy(@NotNull Rel input) { + return new Impl(input, projections); + } + + @NotNull + @Override + public RelProject copy(@NotNull Rel input, @NotNull List projections) { + return new Impl(input, projections); + } + } +} 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 0000000000..5fe47c3444 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelScan.java @@ -0,0 +1,70 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical scan abstract base class. + */ +public abstract class RelScan extends RelBase { + + /** + * @return new {@link RelScan} instance + */ + @NotNull + public static RelScan create(@NotNull Rex rex) { + return new Impl(rex); + } + + /** + * @return input rex (operand 0) + */ + @NotNull + public abstract Rex getRex(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getRex()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitScan(this, ctx); + } + + @NotNull + public abstract RelScan copy(@NotNull Rex rex); + + private static class Impl extends RelScan { + + private final Rex rex; + + private Impl(Rex rex) { + this.rex = rex; + } + + @NotNull + @Override + public Rex getRex() { + return rex; + } + + @NotNull + @Override + public RelScan copy(@NotNull Rex rex) { + return new Impl(rex); + } + } +} 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 0000000000..6af38bd7d6 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelSort.java @@ -0,0 +1,87 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Collation; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical sort abstract base class. + */ +public abstract class RelSort extends RelBase { + + /** + * @return new {@link RelSort} instance + */ + @NotNull + public static RelSort create(@NotNull Rel input, @NotNull List collations) { + return new Impl(input, collations); + } + + @NotNull + public abstract Rel getInput(); + + @NotNull + public abstract List getCollations(); + + @NotNull + @Override + protected final RelType type() { + return getInput().getType(); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitSort(this, ctx); + } + + @NotNull + public abstract RelSort copy(@NotNull Rel input); + + @NotNull + public abstract RelSort copy(@NotNull Rel input, @NotNull List collations); + + private static class Impl extends RelSort { + + private final Rel input; + private final List collations; + + private Impl(Rel input, List collations) { + this.input = input; + this.collations = collations; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public List getCollations() { + return collations; + } + + @NotNull + @Override + public RelSort copy(@NotNull Rel input) { + return new Impl(input, collations); + } + + @NotNull + @Override + public RelSort copy(@NotNull Rel input, @NotNull List collations) { + return new Impl(input, collations); + } + } +} 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 0000000000..fa27f75daf --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java @@ -0,0 +1,65 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.types.Field; + +/** + * Analogous to a ROW type, consider cardinality estimates or other hint mechanisms. + */ +public final class RelType { + + public static final int ORDERED = 0x01; + + private final Field[] fields; + private final boolean ordered; + + private RelType(Field[] fields, boolean ordered) { + this.fields = fields; + this.ordered = ordered; + } + + @NotNull + public static RelType of(Field... fields) { + return of(fields, 0); + } + + @NotNull + public static RelType of(Field[] fields, int properties) { + boolean ordered = (properties & ORDERED) != 0; + return new RelType(fields, ordered); + } + + public int getDegree() { + return fields.length; + } + + @NotNull + public Field[] getFields() { + return fields; + } + + @NotNull + public Field getField(int index) { + if (index < 0 || index >= fields.length) { + throw new IllegalArgumentException("field index out of bounds: " + index); + } + return fields[index]; // bounds check? + } + + @NotNull + public Field getField(String name) { + for (Field field : fields) { + if (field.getName().equals(name)) { + return field; + } + } + throw new IllegalArgumentException("field name not found: " + name); + } + + /** + * @return true if the rel produces an ordered stream of rows. + */ + public boolean isOrdered() { + return ordered; + } +} 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 0000000000..fb54ef4d32 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnion.java @@ -0,0 +1,105 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical union abstract base class. + */ +public abstract class RelUnion extends RelBase { + + /** + * @return new {@link RelUnion} instance + */ + @NotNull + public static RelUnion create(@NotNull Rel left, @NotNull Rel right, boolean all) { + return new Impl(left, right, all); + } + + /** + * @return true if ALL else DISTINCT. + */ + public abstract boolean isAll(); + + /** + * @return left rel (operand 0) + */ + @NotNull + public abstract Rel getLeft(); + + /** + * @return right rel (operand 1) + */ + @NotNull + public abstract Rel getRight(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getLeft()); + Operand c1 = Operand.single(getRight()); + return List.of(c0, c1); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitUnion(this, ctx); + } + + @NotNull + public abstract RelUnion copy(@NotNull Rel left, @NotNull Rel right); + + @NotNull + public abstract RelUnion copy(@NotNull Rel left, @NotNull Rel right, boolean all); + + private static class Impl extends RelUnion { + + private final Rel left; + private final Rel right; + private final boolean all; + + private Impl(Rel left, Rel right, boolean all) { + this.left = left; + this.right = right; + this.all = all; + } + + @Override + public boolean isAll() { + return all; + } + + @NotNull + @Override + public Rel getLeft() { + return left; + } + + @NotNull + @Override + public Rel getRight() { + return right; + } + + @NotNull + @Override + public RelUnion copy(@NotNull Rel left, @NotNull Rel right) { + return new Impl(left, right, all); + } + + @NotNull + @Override + public RelUnion copy(@NotNull Rel left, @NotNull Rel right, boolean all) { + return new Impl(left, right, all); + } + } +} 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 0000000000..31c6256978 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rel/RelUnpivot.java @@ -0,0 +1,70 @@ +package org.partiql.plan.rel; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rex.Rex; + +import java.util.List; + +/** + * Logical unpivot abstract base class. + */ +public abstract class RelUnpivot extends RelBase { + + /** + * @return new {@link RelUnpivot} instance + */ + @NotNull + public static RelUnpivot create(@NotNull Rex rex) { + return new Impl(rex); + } + + /** + * @return input rex (operand 0) + */ + @NotNull + public abstract Rex getRex(); + + @NotNull + @Override + protected final RelType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getRex()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitUnpivot(this, ctx); + } + + @NotNull + public abstract RelUnpivot copy(@NotNull Rex rex); + + private static class Impl extends RelUnpivot { + + private final Rex rex; + + private Impl(Rex rex) { + this.rex = rex; + } + + @NotNull + @Override + public Rex getRex() { + return rex; + } + + @NotNull + @Override + public RelUnpivot copy(@NotNull Rex rex) { + return new Impl(rex); + } + } +} 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 0000000000..8b8029bc8a --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/Rex.java @@ -0,0 +1,21 @@ +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 { + + /** + * @return the type of the value produced by this rex. + */ + @NotNull + public RexType getType(); + + /** + * @param type the new type of the value produced by this rex. + */ + public void setType(RexType type); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.java new file mode 100644 index 0000000000..13e6cec6b5 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexArray.java @@ -0,0 +1,62 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.Operator; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical array expression abstract base class. + */ +public abstract class RexArray extends RexBase { + + /** + * @return new RexArray instance + */ + @NotNull + public static RexArray create(@NotNull List values) { + return new Impl(values); + } + + /** + * @return the values of the array, also the operands. + */ + @NotNull + public abstract List getValues(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.array()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.vararg(getValues()); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitArray(this, ctx); + } + + private static class Impl extends RexArray { + + private final List values; + + private Impl(List values) { + this.values = values; + } + + @NotNull + @Override + public List getValues() { + return values; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.java new file mode 100644 index 0000000000..9f59b900ef --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBag.java @@ -0,0 +1,67 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.Operator; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Logical bag expression abstract base class. + */ +public abstract class RexBag extends RexBase { + + /** + * @return new RexBag instance + */ + @NotNull + public static RexBag create(@NotNull Collection values) { + return new Impl(values); + } + + /** + * @return the values of the bag, also the operands (unordered). + */ + @NotNull + public abstract Collection getValues(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.bag()); + } + + @NotNull + @Override + protected final List operands() { + // uh oh! prescribing order (??) + List values = new ArrayList<>(getValues()); + Operand c0 = Operand.vararg(values); + return List.of(c0); + } + + @Override + public R accept(@NotNull OperatorVisitor visitor, C ctx) { + return visitor.visitBag(this, ctx); + } + + private static class Impl extends RexBag { + + private final Collection values; + + private Impl(Collection values) { + this.values = values; + } + + @NotNull + @Override + public Collection getValues() { + return values; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexBase.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBase.java new file mode 100644 index 0000000000..076b9df2fa --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexBase.java @@ -0,0 +1,74 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; + +import java.util.List; + +/** + * Abstract base class for all scalar expressions. + */ +public abstract class RexBase implements Rex { + + private int tag = 0; + private List operands; + private RexType type; + + @Override + public int getTag() { + return tag; + } + + @Override + public void setTag(int tag) { + this.tag = tag; + } + + @NotNull + @Override + public final RexType getType() { + if (type == null) { + type = type(); + } + return type; + } + + @Override + public final void setType(RexType type) { + this.type = type; + } + + @NotNull + @Override + public final Operand getOperand(int index) { + if (operands == null) { + operands = operands(); + } + return operands.get(index); + } + + @NotNull + @Override + public final List getOperands() { + if (operands == null) { + operands = operands(); + } + return operands; + } + + /** + * PROTECTED (could also be package private atm). + * + * @return computed type. + */ + @NotNull + protected abstract RexType type(); + + /** + * PROTECTED (could also be package private atm). + * + * @return computed operands. + */ + @NotNull + protected abstract List operands(); +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.java new file mode 100644 index 0000000000..f444723f8d --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCall.java @@ -0,0 +1,73 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.spi.function.Function; + +import java.util.List; + +/** + * Logical scalar function expression abstract base class. + */ +public abstract class RexCall extends RexBase { + + @NotNull + public static RexCall create(@NotNull Function.Instance function, @NotNull List args) { + return new Impl(function, args); + } + + /** + * Returns the function to invoke. + */ + @NotNull + public abstract Function.Instance getFunction(); + + /** + * Returns the list of function arguments. + */ + @NotNull + public abstract List getArgs(); + + @NotNull + @Override + protected RexType type() { + return RexType.of(getFunction().returns); + } + + @NotNull + @Override + protected List operands() { + Operand c0 = Operand.vararg(getArgs()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitCall(this, ctx); + } + + private static class Impl extends RexCall { + + private final Function.Instance function; + private final List args; + + private Impl(Function.Instance function, List args) { + this.function = function; + this.args = args; + } + + @NotNull + @Override + public Function.Instance getFunction() { + return function; + } + + @NotNull + @Override + public List getArgs() { + return args; + } + } +} + diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.java new file mode 100644 index 0000000000..43ba348f49 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCase.java @@ -0,0 +1,121 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical case (switch) expression abstract base class. + */ +public abstract class RexCase extends RexBase { + + @NotNull + public static RexCase create(@Nullable Rex match, @NotNull List branches, @Nullable Rex def) { + return new Impl(match, branches, def); + } + + @NotNull + public static Branch branch(@NotNull Rex condition, @NotNull Rex result) { + return new Branch(condition, result); + } + + /** + * @return the match expression, or {@code null} if none (operand 0) + */ + @Nullable + public abstract Rex getMatch(); + + /** + * @return the list of branches (not operands). + */ + @NotNull + public abstract List getBranches(); + + /** + * @return the default expression, or {@code null} if none (not an operand) + */ + @Nullable + public abstract Rex getDefault(); + + @NotNull + @Override + protected final RexType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected List operands() { + Rex match = getMatch(); + if (match == null) { + return List.of(); + } + Operand c0 = Operand.single(match); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitCase(this, ctx); + } + + /** + * A branch of a case expression. + */ + public static class Branch { + + @NotNull + private final Rex condition; + + @NotNull + private final Rex result; + + private Branch(@NotNull Rex condition, @NotNull Rex result) { + this.condition = condition; + this.result = result; + } + + @NotNull + public Rex getCondition() { + return condition; + } + + @NotNull + public Rex getResult() { + return result; + } + } + + private static class Impl extends RexCase { + private final Rex match; + private final List branches; + private final Rex def; + + private Impl(Rex match, List branches, Rex def) { + this.match = match; + this.branches = branches; + this.def = def; + } + + @Nullable + @Override + public Rex getMatch() { + return match; + } + + @NotNull + @Override + public List getBranches() { + return branches; + } + + @Nullable + @Override + public Rex getDefault() { + return def; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.java new file mode 100644 index 0000000000..374b77b3a1 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCast.java @@ -0,0 +1,73 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical cast expression abstract base class. + */ +public abstract class RexCast extends RexBase { + + /** + * @return new RexCast instance + */ + @NotNull + public static RexCast create(@NotNull Rex operand, @NotNull PType target) { + return new Impl(operand, target); + } + + /** + * @return operand rex (operand 0) + */ + @NotNull + public abstract Rex getOperand(); + + /** + * @return target type + */ + @NotNull + public abstract PType getTarget(); + + @NotNull + protected final RexType type() { + return RexType.of(getTarget()); + } + + @NotNull + @Override + protected List operands() { + Operand c0 = Operand.single(getOperand()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitCast(this, ctx); + } + + private static class Impl extends RexCast { + private final Rex operand; + private final PType target; + + private Impl(@NotNull Rex operand, @NotNull PType target) { + this.operand = operand; + this.target = target; + } + + @NotNull + @Override + public Rex getOperand() { + return operand; + } + + @NotNull + @Override + public PType getTarget() { + return target; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.java new file mode 100644 index 0000000000..2440570a7d --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexCoalesce.java @@ -0,0 +1,60 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical coalesce expression abstract base class. + */ +public abstract class RexCoalesce extends RexBase { + + /** + * @return new RexCoalesce instance + */ + @NotNull + public static RexCoalesce create(List args) { + return new Impl(args); + } + + /** + * @return the list of arguments (also the operands). + */ + @NotNull + public abstract List getArgs(); + + @NotNull + @Override + protected final RexType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.vararg(getArgs()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitCoalesce(this, ctx); + } + + private static class Impl extends RexCoalesce { + + private final List args; + + private Impl(List args) { + this.args = args; + } + + @NotNull + @Override + public List getArgs() { + return args; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexDispatch.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexDispatch.java new file mode 100644 index 0000000000..3c1d176eb9 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexDispatch.java @@ -0,0 +1,84 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.spi.function.Function; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical operator for a dynamic dispatch. + */ +public abstract class RexDispatch extends RexBase { + + /** + * @return new RexDispatch instance + */ + @NotNull + public static RexDispatch create(String name, List functions, List args) { + return new Impl(name, functions, args); + } + + /** + * Dynamic function name. + */ + public abstract String getName(); + + /** + * Returns the functions to dispatch to. + */ + public abstract List getFunctions(); + + /** + * Returns the list of function arguments. + */ + public abstract List getArgs(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.dynamic()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.vararg(getArgs()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitDispatch(this, ctx); + } + + private static class Impl extends RexDispatch { + + private final String name; + private final List functions; + private final List args; + + private Impl(String name, List functions, List args) { + this.name = name; + this.functions = functions; + this.args = args; + } + + @Override + public String getName() { + return name; + } + + @Override + public List getFunctions() { + return functions; + } + + @Override + public List getArgs() { + return args; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.java new file mode 100644 index 0000000000..fc1c3d22a1 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexError.java @@ -0,0 +1,45 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.List; + +/** + * This represents scenarios in which certain operations are statically known to fail in strict mode but return missing + * in permissive mode. + */ +public abstract class RexError extends RexBase { + + /** + * @return new RexError instance + */ + @NotNull + public static RexError create() { + return new Impl(); + } + + @NotNull + @Override + protected RexType type() { + // TODO SHOULD BE UNKNOWN + return RexType.of(PType.dynamic()); + } + + @NotNull + @Override + protected List operands() { + return List.of(); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitError(this, ctx); + } + + private static class Impl extends RexError { + // empty + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.java new file mode 100644 index 0000000000..86b9129ee9 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexLit.java @@ -0,0 +1,57 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.spi.value.Datum; + +import java.util.List; + +/** + * Literal value expression abstract base class. + */ +public abstract class RexLit extends RexBase { + + /** + * @return new RexLit instance + */ + @NotNull + public static RexLit create(@NotNull Datum value) { + return new Impl(value); + } + + @NotNull + public abstract Datum getDatum(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(getDatum().getType()); + } + + @NotNull + @Override + protected List operands() { + return List.of(); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitLit(this, ctx); + } + + private static class Impl extends RexLit { + + private final Datum value; + + private Impl(Datum value) { + this.value = value; + } + + @NotNull + @Override + public Datum getDatum() { + return value; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.java new file mode 100644 index 0000000000..1909f8fae7 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexNullIf.java @@ -0,0 +1,79 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical nullif expression abstraction base class. + */ +public abstract class RexNullIf extends RexBase { + + /** + * @return new RexNullIf instance + */ + @NotNull + public static RexNullIf create(@NotNull Rex v1, @NotNull Rex v2) { + return new Impl(v1, v2); + } + + /** + * @return v1 rex (operand 0) + */ + @NotNull + public abstract Rex getV1(); + + /** + * @return v2 rex (operand 1) + */ + @NotNull + public abstract Rex getV2(); + + /** + * @return minimal common supertype of (NULL, typeof(v1)) + */ + @NotNull + @Override + protected final RexType type() { + + return getV1().getType(); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getV1()); + Operand c1 = Operand.single(getV2()); + return List.of(c0, c1); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitNullIf(this, ctx); + } + + private static class Impl extends RexNullIf { + + private final Rex v1; + private final Rex v2; + + private Impl(Rex v1, Rex v2) { + this.v1 = v1; + this.v2 = v2; + } + + @NotNull + @Override + public Rex getV1() { + return v1; + } + + @NotNull + @Override + public Rex getV2() { + return v2; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.java new file mode 100644 index 0000000000..4f7b54a013 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathIndex.java @@ -0,0 +1,73 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical path by index expression abstract base class. + */ +public abstract class RexPathIndex extends RexBase { + + /** + * @return new RexPathIndex instance + */ + @NotNull + public static RexPathIndex create(@NotNull Rex operand, @NotNull Rex index) { + return new Impl(operand, index); + } + + /** + * @return operand rex (operand 0) + */ + @NotNull + public abstract Rex getOperand(); + + /** + * @return index rex + */ + public abstract Rex getIndex(); + + @Override + @NotNull + protected final RexType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getOperand()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitPathIndex(this, ctx); + } + + private static class Impl extends RexPathIndex { + + private final Rex operand; + private final Rex index; + + private Impl(@NotNull Rex operand, @NotNull Rex index) { + this.operand = operand; + this.index = index; + } + + @NotNull + @Override + public Rex getOperand() { + return operand; + } + + @NotNull + @Override + public Rex getIndex() { + return index; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.java new file mode 100644 index 0000000000..90765f2ea2 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathKey.java @@ -0,0 +1,74 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical path by key lookup expression abstract base class. + */ +public abstract class RexPathKey extends RexBase { + + /** + * @return new RexPathKey instance + */ + @NotNull + public static RexPathKey create(@NotNull Rex operand, @NotNull Rex key) { + return new Impl(operand, key); + } + + /** + * @return operand rex (operand 0) + */ + @NotNull + public abstract Rex getOperand(); + + /** + * @return key rex. + */ + @NotNull + public abstract Rex getKey(); + + @Override + @NotNull + protected final RexType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected List operands() { + Operand c0 = Operand.single(getOperand()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitPathKey(this, ctx); + } + + private static class Impl extends RexPathKey { + + private final Rex operand; + private final Rex key; + + private Impl(@NotNull Rex operand, @NotNull Rex key) { + this.operand = operand; + this.key = key; + } + + @NotNull + @Override + public Rex getOperand() { + return operand; + } + + @NotNull + @Override + public Rex getKey() { + return key; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.java new file mode 100644 index 0000000000..6240f57a0c --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPathSymbol.java @@ -0,0 +1,74 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; + +import java.util.List; + +/** + * Logical path by symbol lookup expression abstract base class. + */ +public abstract class RexPathSymbol extends RexBase { + + /** + * @return new RexPathSymbol instance + */ + @NotNull + public static RexPathSymbol create(@NotNull Rex operand, @NotNull String symbol) { + return new Impl(operand, symbol); + } + + /** + * @return operand rex (operand 0) + */ + @NotNull + public abstract Rex getOperand(); + + /** + * @return symbol string + */ + @NotNull + public abstract String getSymbol(); + + @Override + @NotNull + protected final RexType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getOperand()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitPathSymbol(this, ctx); + } + + private static class Impl extends RexPathSymbol { + + private final Rex operand; + private final String symbol; + + private Impl(@NotNull Rex operand, @NotNull String symbol) { + this.operand = operand; + this.symbol = symbol; + } + + @NotNull + @Override + public Rex getOperand() { + return operand; + } + + @NotNull + @Override + public String getSymbol() { + return symbol; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.java new file mode 100644 index 0000000000..91a2291151 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexPivot.java @@ -0,0 +1,90 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rel.Rel; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical pivot expression abstract base class. + */ +public abstract class RexPivot extends RexBase { + + /** + * @return new RexPivot instance + */ + @NotNull + public static RexPivot create(@NotNull Rel input, @NotNull Rex key, @NotNull Rex value) { + return new Impl(input, key, value); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return key rex (operand 1) + */ + @NotNull + public abstract Rex getKey(); + + /** + * @return value rex (operand 2) + */ + @NotNull + public abstract Rex getValue(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.struct()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitPivot(this, ctx); + } + + private static class Impl extends RexPivot { + + private final Rel input; + private final Rex key; + private final Rex value; + + private Impl(Rel input, Rex key, Rex value) { + this.input = input; + this.key = key; + this.value = value; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Rex getKey() { + return key; + } + + @NotNull + @Override + public Rex getValue() { + return value; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.java new file mode 100644 index 0000000000..7eb830f7e7 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSelect.java @@ -0,0 +1,75 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rel.Rel; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical select expression abstract base class. + */ +public abstract class RexSelect extends RexBase { + + /** + * @return new RexSelect instance + */ + @NotNull + public static RexSelect create(@NotNull Rel input, @NotNull Rex constructor) { + return new Impl(input, constructor); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return constructor rex. + */ + public abstract Rex getConstructor(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.bag()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitSelect(this, ctx); + } + + private static class Impl extends RexSelect { + + private final Rel input; + private final Rex constructor; + + private Impl(Rel input, Rex constructor) { + this.input = input; + this.constructor = constructor; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Rex getConstructor() { + return constructor; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.java new file mode 100644 index 0000000000..3f86e5882a --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSpread.java @@ -0,0 +1,59 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.Operator; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical spread expression abstract base class. + */ +public abstract class RexSpread extends RexBase { + + /** + * @return new RexSpread instance + */ + @NotNull + public static RexSpread create(@NotNull List args) { + return new Impl(args); + } + + /** + * @return list of spread arguments (the operands) + */ + public abstract List getArgs(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.struct()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.vararg(getArgs()); + return List.of(c0); + } + + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitSpread(this, ctx); + } + + private static class Impl extends RexSpread { + + private final List args; + + private Impl(List args) { + this.args = args; + } + + @Override + public List getArgs() { + return args; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.java new file mode 100644 index 0000000000..74e6362dd2 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexStruct.java @@ -0,0 +1,91 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical struct expression abstract base class. + */ +public abstract class RexStruct extends RexBase { + + /** + * @return new RexStruct instance + */ + @NotNull + public static RexStruct create(@NotNull List fields) { + return new Impl(fields); + } + + /** + * @return a field constructor instance + */ + @NotNull + public static Field field(Rex key, Rex value) { + return new Field(key, value); + } + + /** + * @return list of struct fields (NOT operands) + */ + @NotNull + public abstract List getFields(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.struct()); + } + + @NotNull + @Override + protected List operands() { + return List.of(); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitStruct(this, ctx); + } + + /** + * Struct expression field constructor. + */ + public static class Field { + + private final Rex key; + private final Rex value; + + private Field(Rex key, Rex value) { + this.key = key; + this.value = value; + } + + public Rex getKey() { + return key; + } + + public Rex getValue() { + return value; + } + } + + private static class Impl extends RexStruct { + + @NotNull + private final List fields; + + private Impl(@NotNull List fields) { + this.fields = fields; + } + + @Override + @NotNull + public List getFields() { + return fields; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.java new file mode 100644 index 0000000000..11dff39af5 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubquery.java @@ -0,0 +1,83 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rel.Rel; + +import java.util.List; + +/** + * Logical subquery expression abstract base class. + */ +public abstract class RexSubquery extends RexBase { + + /** + * @return new RexSubquery instance + */ + @NotNull + public static RexSubquery create(@NotNull Rel input, @NotNull Rex constructor, boolean scalar) { + return new Impl(input, constructor, scalar); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + // TODO REMOVE ME – TEMPORARY UNTIL PLANNER PROPERLY HANDLES SUBQUERIES + @NotNull + public abstract Rex getConstructor(); + + // TODO REMOVE ME – TEMPORARY UNTIL PLANNER PROPERLY HANDLES SUBQUERIES + public abstract boolean isScalar(); + + @NotNull + @Override + protected final RexType type() { + throw new UnsupportedOperationException("Derive type is not implemented"); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitSubquery(this, ctx); + } + + private static class Impl extends RexSubquery { + + private final Rel input; + private final Rex constructor; + private final boolean scalar; + + private Impl(Rel input, Rex constructor, boolean scalar) { + this.input = input; + this.constructor = constructor; + this.scalar = scalar; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Rex getConstructor() { + return constructor; + } + + @Override + public boolean isScalar() { + return scalar; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.java new file mode 100644 index 0000000000..f1e907412d --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryComp.java @@ -0,0 +1,190 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rel.Rel; +import org.partiql.spi.Enum; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical subquery comparison expression abstract base class. + *

+ * See SQL-99 and . + */ +public abstract class RexSubqueryComp extends RexBase { + + /** + * @return new RexSubqueryComp instance + */ + @NotNull + public static RexSubqueryComp create( + @NotNull Rel input, + @NotNull List args, + @NotNull Comparison comparison, + @NotNull Quantifier quantifier + ) { + return new Impl(input, args, comparison, quantifier); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return collection comparison arguments (not operands). + */ + @NotNull + public abstract List getArgs(); + + /** + * @return subquery comparison operator + */ + @NotNull + public abstract Comparison getComparison(); + + /** + * @return subquery comparison quantifier + */ + @NotNull + public abstract Quantifier getQuantifier(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.bool()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitSubqueryComp(this, ctx); + } + + /** + * SQL for use in the . + */ + public static class Comparison extends Enum { + + private Comparison(int code) { + super(code); + } + + public static final int UNKNOWN = 0; + public static final int EQ = 1; + public static final int NE = 2; + public static final int LT = 3; + public static final int LE = 4; + public static final int GT = 5; + public static final int GE = 6; + + @NotNull + public static Comparison EQ() { + return new Comparison(EQ); + } + + @NotNull + public static Comparison NE() { + return new Comparison(NE); + } + + @NotNull + public static Comparison LT() { + return new Comparison(LT); + } + + @NotNull + public static Comparison LE() { + return new Comparison(LE); + } + + @NotNull + public static Comparison GT() { + return new Comparison(GT); + } + + @NotNull + public static Comparison GE() { + return new Comparison(GE); + } + } + + /** + * SQL for use in the . + */ + public static class Quantifier extends Enum { + + private Quantifier(int code) { + super(code); + } + + public static final int UNKNOWN = 0; + public static final int ANY = 1; + public static final int ALL = 2; + public static final int SOME = 3; + + @NotNull + public static Quantifier ANY() { + return new Quantifier(ANY); + } + + @NotNull + public static Quantifier ALL() { + return new Quantifier(ALL); + } + + @NotNull + public static Quantifier SOME() { + return new Quantifier(SOME); + } + } + + private static class Impl extends RexSubqueryComp { + + private final Rel input; + private final List args; + private final Comparison comparison; + private final Quantifier quantifier; + + private Impl(Rel input, List args, Comparison comparison, Quantifier quantifier) { + this.input = input; + this.args = args; + this.comparison = comparison; + this.quantifier = quantifier; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public List getArgs() { + return args; + } + + @NotNull + @Override + public Comparison getComparison() { + return comparison; + } + + @NotNull + @Override + public Quantifier getQuantifier() { + return quantifier; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.java new file mode 100644 index 0000000000..02b9b34ee5 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryIn.java @@ -0,0 +1,76 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rel.Rel; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical subquery in expression abstract base class. + */ +public abstract class RexSubqueryIn extends RexBase { + + /** + * @return new RexSubqueryIn instance + */ + @NotNull + public static RexSubqueryIn create(@NotNull Rel input, @NotNull List args) { + return new Impl(input, args); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return collection comparison arguments (not operands). + */ + @NotNull + public abstract List getArgs(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.bool()); + } + + @NotNull + @Override + protected final List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitSubqueryIn(this, ctx); + } + + private static class Impl extends RexSubqueryIn { + + private final Rel input; + private final List args; + + private Impl(Rel input, List args) { + this.input = input; + this.args = args; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public List getArgs() { + return args; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.java new file mode 100644 index 0000000000..da590b9ecd --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexSubqueryTest.java @@ -0,0 +1,106 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.plan.rel.Rel; +import org.partiql.spi.Enum; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical subquery test expression abstract base class. + *
+ *

+ *  -     "Specify a test for a non-empty set."
+ *  -     "Specify a test for the absence of duplicate rows."
+ * 
+ */ +public abstract class RexSubqueryTest extends RexBase { + + /** + * @return new RexSubqueryTest instance + */ + @NotNull + public static RexSubqueryTest create(@NotNull Rel input, @NotNull Test test) { + return new Impl(input, test); + } + + /** + * @return input rel (operand 0) + */ + @NotNull + public abstract Rel getInput(); + + /** + * @return subquery test + */ + @NotNull + public abstract Test getTest(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(PType.bool()); + } + + @NotNull + @Override + protected List operands() { + Operand c0 = Operand.single(getInput()); + return List.of(c0); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitSubqueryTest(this, ctx); + } + + /** + * EXISTS and UNIQUE are defined by SQL. + */ + public static class Test extends Enum { + + public static final int UNKNOWN = 0; + public static final int EXISTS = 1; + public static final int UNIQUE = 2; + + private Test(int code) { + super(code); + } + + @NotNull + public static Test EXISTS() { + return new Test(EXISTS); + } + + @NotNull + public static Test UNIQUE() { + return new Test(UNIQUE); + } + } + + private static class Impl extends RexSubqueryTest { + + private final Rel input; + private final Test test; + + private Impl(Rel input, Test test) { + this.input = input; + this.test = test; + } + + @NotNull + @Override + public Rel getInput() { + return input; + } + + @NotNull + @Override + public Test getTest() { + return test; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.java new file mode 100644 index 0000000000..cc073d79e5 --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexTable.java @@ -0,0 +1,58 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.spi.catalog.Table; + +import java.util.List; + +/** + * Global variable references e.g. tables and views. + */ +public abstract class RexTable extends RexBase { + + /** + * @return new RexTable instance + */ + @NotNull + public static RexTable create(@NotNull Table table) { + return new Impl(table); + } + + /** + * @return the table implementation. + */ + public abstract Table getTable(); + + @NotNull + @Override + protected final RexType type() { + return RexType.of(getTable().getSchema()); + } + + @NotNull + @Override + protected final List operands() { + return List.of(); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitTable(this, ctx); + } + + private static class Impl extends RexTable { + + private final Table table; + + private Impl(Table table) { + this.table = table; + } + + @Override + public Table getTable() { + return table; + } + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexType.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexType.java new file mode 100644 index 0000000000..a02b64ae0e --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexType.java @@ -0,0 +1,56 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.types.PType; + +/** + * [RexType] is a simple wrapper over [PType], but does not necessarily only hold a PType. + *

+ *

+ * Developer Note: In later releases, a [RexType] may hold metadata to aid custom planner implementations. + */ +public final class RexType { + + private final PType type; + + private RexType(PType type) { + this.type = type; + } + + /** + * @return a RexType from a PType. + */ + @NotNull + public static RexType of(@NotNull PType type) { + return new RexType(type); + } + + @NotNull + public PType getPType() { + return type; + } + + @Override + public int hashCode() { + return type.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof RexType)) { + return false; + } + return type.equals(((RexType) obj).type); + } + + @Override + public String toString() { + return type.toString(); + } +} diff --git a/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.java b/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.java new file mode 100644 index 0000000000..05a18460ce --- /dev/null +++ b/partiql-plan/src/main/java/org/partiql/plan/rex/RexVar.java @@ -0,0 +1,72 @@ +package org.partiql.plan.rex; + +import org.jetbrains.annotations.NotNull; +import org.partiql.plan.Operand; +import org.partiql.plan.OperatorVisitor; +import org.partiql.types.PType; + +import java.util.List; + +/** + * Logical variable reference expression abstract base class. + */ +public abstract class RexVar extends RexBase { + + /** + * @return new variable reference expression. + */ + @NotNull + public static RexVar create(int scope, int offset, PType type) { + return new Impl(scope, offset, type); + } + + /** + * @return 0-indexed scope offset. + */ + public abstract int getScope(); + + /** + * @return 0-index tuple offset. + */ + public abstract int getOffset(); + + @NotNull + @Override + protected final List operands() { + return List.of(); + } + + @Override + public R accept(OperatorVisitor visitor, C ctx) { + return visitor.visitVar(this, ctx); + } + + private static class Impl extends RexVar { + + private final int scope; + private final int offset; + private final PType type; + + private Impl(int scope, int offset, PType type) { + this.scope = scope; + this.offset = offset; + this.type = type; + } + + @NotNull + @Override + protected RexType type() { + return RexType.of(type); + } + + @Override + public int getScope() { + return scope; + } + + @Override + public int getOffset() { + return offset; + } + } +} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/AggregateCall.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/AggregateCall.kt deleted file mode 100644 index 7d1cf0b8f1..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/AggregateCall.kt +++ /dev/null @@ -1,37 +0,0 @@ -package org.partiql.plan - -import org.partiql.plan.rex.Rex -import org.partiql.spi.function.Aggregation - -/** - * TODO DOCUMENTATION - * - * TODO this does not need to be an interface. - */ -public interface AggregateCall { - - public fun getAgg(): Aggregation - - public fun getArgs(): List - - public fun isDistinct(): Boolean -} - -/** - * Internal standard implementation of [AggregateCall]. - * - * DO NOT USE FINAL. - * - * @property agg - * @property args - * @property isDistinct - */ -internal class RelAggregateCallImpl( - private var agg: Aggregation, - private var args: List, - private var isDistinct: Boolean, -) : AggregateCall { - override fun getAgg(): Aggregation = agg - override fun getArgs(): List = args - override fun isDistinct(): Boolean = isDistinct -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Collation.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Collation.kt deleted file mode 100644 index bf052768fd..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Collation.kt +++ /dev/null @@ -1,30 +0,0 @@ -package org.partiql.plan - -import org.partiql.plan.rex.Rex - -/** - * TODO DOCUMENTATION - */ -public interface Collation { - - /** - * TODO REPLACE WITH COLUMN INDEX - */ - public fun getRex(): Rex - - public fun getOrder(): Order - - public fun getNulls(): Nulls - - public enum class Order { - ASC, - DESC, - OTHER, - } - - public enum class Nulls { - FIRST, - LAST, - OTHER, - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/JoinType.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/JoinType.kt deleted file mode 100644 index 4fd9c8302c..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/JoinType.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.partiql.plan - -/** - * PartiQL JOIN types. - * - * TODO use 1.0 enum modeling. - */ -public enum class JoinType { - INNER, - LEFT, - RIGHT, - FULL, -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Operation.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Operation.kt deleted file mode 100644 index ae44824016..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Operation.kt +++ /dev/null @@ -1,26 +0,0 @@ -package org.partiql.plan - -import org.partiql.plan.rex.Rex -import org.partiql.plan.rex.RexType - -/** - * TODO DOCUMENTATION - */ -public interface Operation { - - /** - * PartiQL Query Statement — i.e. SELECT-FROM - */ - public interface Query : Operation { - - /** - * Returns the root expression of the query. - */ - public fun getRex(): Rex - - /** - * Returns the type of the root expression of the query. - */ - public fun getType(): RexType = getRex().getType() - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Operator.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Operator.kt deleted file mode 100644 index 083e27a2c1..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Operator.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.partiql.plan - -/** - * Operator is the interface for a logical plan operator. - */ -public interface Operator { - - public fun accept(visitor: Visitor, ctx: C): R - - /** - * Get i-th child (input) operator. - * - * @param index - */ - public fun getChild(index: Int) { - throw UnsupportedOperationException("getChild") - } - - /** - * Get all child (input) operators. - * - * @return - */ - public fun getChildren(): Collection -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Operators.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Operators.kt new file mode 100644 index 0000000000..5727889039 --- /dev/null +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/Operators.kt @@ -0,0 +1,444 @@ +package org.partiql.plan + +import org.partiql.plan.rel.Rel +import org.partiql.plan.rel.RelAggregate +import org.partiql.plan.rel.RelAggregate.Measure +import org.partiql.plan.rel.RelCorrelate +import org.partiql.plan.rel.RelDistinct +import org.partiql.plan.rel.RelExcept +import org.partiql.plan.rel.RelExclude +import org.partiql.plan.rel.RelFilter +import org.partiql.plan.rel.RelIntersect +import org.partiql.plan.rel.RelIterate +import org.partiql.plan.rel.RelJoin +import org.partiql.plan.rel.RelLimit +import org.partiql.plan.rel.RelOffset +import org.partiql.plan.rel.RelProject +import org.partiql.plan.rel.RelScan +import org.partiql.plan.rel.RelSort +import org.partiql.plan.rel.RelUnion +import org.partiql.plan.rel.RelUnpivot +import org.partiql.plan.rex.Rex +import org.partiql.plan.rex.RexArray +import org.partiql.plan.rex.RexBag +import org.partiql.plan.rex.RexCall +import org.partiql.plan.rex.RexCase +import org.partiql.plan.rex.RexCast +import org.partiql.plan.rex.RexCoalesce +import org.partiql.plan.rex.RexDispatch +import org.partiql.plan.rex.RexError +import org.partiql.plan.rex.RexLit +import org.partiql.plan.rex.RexNullIf +import org.partiql.plan.rex.RexPathIndex +import org.partiql.plan.rex.RexPathKey +import org.partiql.plan.rex.RexPathSymbol +import org.partiql.plan.rex.RexPivot +import org.partiql.plan.rex.RexSelect +import org.partiql.plan.rex.RexSpread +import org.partiql.plan.rex.RexStruct +import org.partiql.plan.rex.RexSubquery +import org.partiql.plan.rex.RexSubqueryComp +import org.partiql.plan.rex.RexSubqueryIn +import org.partiql.plan.rex.RexSubqueryTest +import org.partiql.plan.rex.RexTable +import org.partiql.plan.rex.RexVar +import org.partiql.spi.catalog.Table +import org.partiql.spi.function.Function +import org.partiql.spi.value.Datum +import org.partiql.types.PType + +/** + * The [Operators] interface is a factory to instantiate operator implementations. + * + * There is only ONE factory method per operators – i.e. no overloads or defaults. + */ +public interface Operators { + + public companion object { + + /** + * A singleton of the [Operators] with all the standard implementations. + */ + @JvmField + public val STANDARD: Operators = object : Operators {} + } + + // --- REL OPERATORS ----------------------------------------------------------------------------------------------- + + /** + * Create a [RelAggregate] instance. + * + * @param input + * @param measures + * @param groups + * + * @param input + */ + public fun aggregate( + input: Rel, + measures: List, + groups: List, + ): RelAggregate = RelAggregate.create(input, measures, groups) + + /** + * Create a [RelCorrelate] instance for a lateral join or correlated subquery. + * + * @param lhs + * @param rhs + * @param joinType + * @return + */ + public fun correlate( + lhs: Rel, + rhs: Rel, + joinType: JoinType, + ): RelCorrelate = RelCorrelate.create(lhs, rhs, joinType) + + /** + * Create a [RelDistinct] instance. + * + * @param input + * @return + */ + public fun distinct(input: Rel): RelDistinct = RelDistinct.create(input) + + /** + * Create a [RelExcept] instance for EXCEPT [ALL|DISTINCT]. + * + * @param lhs + * @param rhs + * @return + */ + public fun except( + lhs: Rel, + rhs: Rel, + all: Boolean, + ): RelExcept = RelExcept.create(lhs, rhs, all) + + /** + * Create a [RelExclude] instance. + * + * @param input + * @param exclusions + * @return + */ + public fun exclude(input: Rel, exclusions: List): RelExclude = RelExclude.create(input, exclusions) + + /** + * Create a [RelFilter] instance. + * + * @param input + * @param predicate + * @return + */ + public fun filter(input: Rel, predicate: Rex): RelFilter = RelFilter.create(input, predicate) + + /** + * Create a [RelIntersect] instance for INTERSECT [ALL|DISTINCT]. + * + * @param lhs + * @param rhs + * @param all + * @return + */ + public fun intersect( + lhs: Rel, + rhs: Rel, + all: Boolean, + ): RelIntersect = RelIntersect.create(lhs, rhs, all) + + /** + * Create a [RelIterate] instance. + * + * @param rex + * @return + */ + public fun iterate(rex: Rex): RelIterate = RelIterate.create(rex) + + /** + * Create a [RelJoin] instance. + * + * @param lhs + * @param rhs + * @param condition + * @param type + * @return + */ + public fun join( + lhs: Rel, + rhs: Rel, + condition: Rex, + type: JoinType, + ): RelJoin = RelJoin.create(lhs, rhs, condition, type) + + /** + * Create a [RelLimit] instance. + * + * @param input + * @param limit + * @return + */ + public fun limit(input: Rel, limit: Rex): RelLimit = RelLimit.create(input, limit) + + /** + * Create a [RelOffset] instance. + * + * @param input + * @param offset + * @return + */ + public fun offset(input: Rel, offset: Rex): RelOffset = RelOffset.create(input, offset) + + /** + * Create a [RelProject] instance. + * + * @param input + * @param projections + * @return + */ + public fun project(input: Rel, projections: List): RelProject = RelProject.create(input, projections) + + /** + * Create a [RelScan] instance. + * + * @param rex + * @return + */ + public fun scan(rex: Rex): RelScan = RelScan.create(rex) + + /** + * Create a [RelSort] instance. + * + * @param input + * @param collations + * @return + */ + public fun sort(input: Rel, collations: List): RelSort = RelSort.create(input, collations) + + /** + * Create a [RelUnion] instance for UNION [ALL|DISTINCT]. + * + * @param lhs + * @param rhs + * @return + */ + public fun union(lhs: Rel, rhs: Rel, all: Boolean): RelUnion = RelUnion.create(lhs, rhs, all) + + /** + * Create a [RelUnpivot] instance. + * + * @param rex + * @return + */ + public fun unpivot(rex: Rex): RelUnpivot = RelUnpivot.create(rex) + + // --- REX OPERATORS ----------------------------------------------------------------------------------------------- + + /** + * Create a [RexArray] instance. + * + * @param values + * @return + */ + public fun array(values: List): RexArray = RexArray.create(values) + + /** + * Create a [RexBag] instance. + * + * @param values + * @return + */ + public fun bag(values: Collection): RexBag = RexBag.create(values) + + /** + * Create a [RexCall] instance. + * + * @param function + * @param args + * @return + */ + public fun call(function: Function.Instance, args: List): RexCall = RexCall.create(function, args) + + /** + * Create a [RexCase] instance for a case-when with dynamic type (case is a reserved word in Java). + * + * @param match + * @param branches + * @param default + * @return + */ + public fun caseWhen(match: Rex?, branches: List, default: Rex?): RexCase = + RexCase.create(match, branches, default) + + /** + * Create a [RexCast] instance. + * + * @param operand + * @param target + * @return + */ + public fun cast(operand: Rex, target: PType): RexCast = RexCast.create(operand, target) + + /** + * Create a [RexCoalesce] instance. + * + * @param args + * @return + */ + public fun coalesce(args: List): RexCoalesce = RexCoalesce.create(args) + + /** + * Create a [RexDispatch] instance. + * + * @param name + * @param functions + * @param args + * @return + */ + public fun dispatch(name: String, functions: List, args: List): RexDispatch = + RexDispatch.create(name, functions, args) + + /** + * Create a [RexError] instance. + */ + public fun error(type: PType): RexError = RexError.create() + + /** + * Create a [RexLit] instance. + * + * @param value + * @return + */ + public fun lit(value: Datum): RexLit = RexLit.create(value) + + /** + * Create a [RexNullIf] instance. + */ + public fun nullIf(v1: Rex, v2: Rex): RexNullIf = RexNullIf.create(v1, v2) + + /** + * Create a [RexPathIndex] instance. + * + * @param operand + * @param index + * @return + */ + public fun pathIndex(operand: Rex, index: Rex): RexPathIndex = RexPathIndex.create(operand, index) + + /** + * Create a [RexPathKey] instance. + * + * @param operand + * @param key + * @return + */ + public fun pathKey(operand: Rex, key: Rex): RexPathKey = RexPathKey.create(operand, key) + + /** + * Create a [RexPathSymbol] instance. + * + * @param operand + * @param symbol + * @return + */ + public fun pathSymbol(operand: Rex, symbol: String): RexPathSymbol = RexPathSymbol.create(operand, symbol) + + /** + * Create a [RexPivot] instance. + * + * @param input + * @param key + * @param value + * @return + */ + public fun pivot(input: Rel, key: Rex, value: Rex): RexPivot = RexPivot.create(input, key, value) + + /** + * Create a [RexSelect] instance. + * + * @param input + * @param constructor + * @return + */ + public fun select(input: Rel, constructor: Rex): RexSelect = RexSelect.create(input, constructor) + + /** + * Create a [RexSpread] instance with open struct type. + * + * @param args + * @return + */ + public fun spread(args: List): RexSpread = RexSpread.create(args) + + /** + * Create a [RexStruct] instance. + * + * @param fields + * @return + */ + public fun struct(fields: List): RexStruct = RexStruct.create(fields) + + /** + * Create a [RexSubquery] instance. + * + * TODO REMOVE constructor AND scalar – TEMPORARY UNTIL SUBQUERIES ARE FIXED IN THE PLANNER. + * + * @param input + * @return + */ + public fun subquery(input: Rel, constructor: Rex, scalar: Boolean): RexSubquery = + RexSubquery.create(input, constructor, scalar) + + /** + * Create a [RexSubqueryComp] instance. + * + * @param input + * @param args + * @param comparison + * @param quantifier + * @return + */ + public fun subqueryComp( + input: Rel, + args: List, + comparison: RexSubqueryComp.Comparison, + quantifier: RexSubqueryComp.Quantifier, + ): RexSubqueryComp = RexSubqueryComp.create(input, args, comparison, quantifier) + + /** + * Create a [RexSubqueryIn] instance for a list argument. + * + * @param input + * @param args + * @return + */ + public fun subqueryIn(input: Rel, args: List): RexSubqueryIn = RexSubqueryIn.create(input, args) + + /** + * Create a [RexSubqueryTest] instance. + * + * @param input + * @param test + * @return + */ + public fun subqueryTest(input: Rel, test: RexSubqueryTest.Test): RexSubqueryTest = + RexSubqueryTest.create(input, test) + + /** + * Create a [RexTable] instance. + * + * @param table + * @return + */ + public fun table(table: Table): RexTable = RexTable.create(table) + + /** + * Create a [RexVar] instance (requires a type). + * + * @param depth + * @param offset + * @param type + * @return + */ + public fun variable(depth: Int, offset: Int, type: PType): RexVar = RexVar.create(depth, offset, type) +} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Plan.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Plan.kt deleted file mode 100644 index 5003e92ac6..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Plan.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.partiql.plan - -/** - * A [Plan] holds operations that can be executed. - */ -public interface Plan { - - /** - * The plan version for serialization and debugging. - * - * @return - */ - public fun getVersion(): Version = object : Version { - override fun toString(): String = "1" - } - - /** - * The plan operation to execute. - * - * TODO consider `getOperations(): List`. - * - * @return - */ - public fun getOperation(): Operation -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Version.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Version.kt deleted file mode 100644 index ff24df802e..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Version.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.partiql.plan - -/** - * Marker interface for some version structure. - */ -public interface Version { - - /** - * The only required method is toString. - */ - override fun toString(): String -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/Visitor.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/Visitor.kt deleted file mode 100644 index 29b5ca0e7f..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/Visitor.kt +++ /dev/null @@ -1,143 +0,0 @@ -package org.partiql.plan - -import org.partiql.plan.rel.RelAggregate -import org.partiql.plan.rel.RelCorrelate -import org.partiql.plan.rel.RelDistinct -import org.partiql.plan.rel.RelExcept -import org.partiql.plan.rel.RelExclude -import org.partiql.plan.rel.RelFilter -import org.partiql.plan.rel.RelIntersect -import org.partiql.plan.rel.RelIterate -import org.partiql.plan.rel.RelJoin -import org.partiql.plan.rel.RelLimit -import org.partiql.plan.rel.RelOffset -import org.partiql.plan.rel.RelProject -import org.partiql.plan.rel.RelScan -import org.partiql.plan.rel.RelSort -import org.partiql.plan.rel.RelUnion -import org.partiql.plan.rel.RelUnpivot -import org.partiql.plan.rex.RexArray -import org.partiql.plan.rex.RexBag -import org.partiql.plan.rex.RexCall -import org.partiql.plan.rex.RexCallDynamic -import org.partiql.plan.rex.RexCase -import org.partiql.plan.rex.RexCast -import org.partiql.plan.rex.RexCoalesce -import org.partiql.plan.rex.RexError -import org.partiql.plan.rex.RexLit -import org.partiql.plan.rex.RexNullIf -import org.partiql.plan.rex.RexPathIndex -import org.partiql.plan.rex.RexPathKey -import org.partiql.plan.rex.RexPathSymbol -import org.partiql.plan.rex.RexPivot -import org.partiql.plan.rex.RexSelect -import org.partiql.plan.rex.RexSpread -import org.partiql.plan.rex.RexStruct -import org.partiql.plan.rex.RexSubquery -import org.partiql.plan.rex.RexSubqueryComp -import org.partiql.plan.rex.RexSubqueryIn -import org.partiql.plan.rex.RexSubqueryTest -import org.partiql.plan.rex.RexTable -import org.partiql.plan.rex.RexVar - -/** - * A visitor for a logical [Operator] tree. - * - * @param R Visit return type - * @param C Context parameter type - */ -public interface Visitor { - - public fun defaultVisit(operator: Operator, ctx: C): R { - for (child in operator.getChildren()) { - child.accept(this, ctx) - } - return defaultReturn(operator, ctx) - } - - public fun defaultReturn(operator: Operator, ctx: C): R - - public fun visit(operator: Operator, ctx: C): R = operator.accept(this, ctx) - - // --[Rel]----------------------------------------------------------------------------------------------------------- - - public fun visitAggregate(rel: RelAggregate, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitDistinct(rel: RelDistinct, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitExcept(rel: RelExcept, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitExclude(rel: RelExclude, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitFilter(rel: RelFilter, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitIntersect(rel: RelIntersect, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitIterate(rel: RelIterate, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitJoin(rel: RelJoin, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitCorrelate(rel: RelCorrelate, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitLimit(rel: RelLimit, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitOffset(rel: RelOffset, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitProject(rel: RelProject, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitScan(rel: RelScan, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitSort(rel: RelSort, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitUnion(rel: RelUnion, ctx: C): R = defaultVisit(rel, ctx) - - public fun visitUnpivot(rel: RelUnpivot, ctx: C): R = defaultVisit(rel, ctx) - - // --[Rex]----------------------------------------------------------------------------------------------------------- - - public fun visitArray(rex: RexArray, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitBag(rex: RexBag, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitCall(rex: RexCall, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitCallDynamic(rex: RexCallDynamic, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitCase(rex: RexCase, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitCast(rex: RexCast, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitCoalesce(rex: RexCoalesce, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitError(rex: RexError, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitLit(rex: RexLit, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitNullIf(rex: RexNullIf, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitPathIndex(rex: RexPathIndex, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitPathKey(rex: RexPathKey, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitPathSymbol(rex: RexPathSymbol, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitPivot(rex: RexPivot, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitSelect(rex: RexSelect, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitStruct(rex: RexStruct, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitSubquery(rex: RexSubquery, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitSubqueryComp(rex: RexSubqueryComp, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitSubqueryIn(rex: RexSubqueryIn, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitSubqueryTest(rex: RexSubqueryTest, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitSpread(rex: RexSpread, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitTable(rex: RexTable, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitVar(rex: RexVar, ctx: C): R = defaultVisit(rex, ctx) -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/.keep b/partiql-plan/src/main/kotlin/org/partiql/plan/builder/.keep new file mode 100644 index 0000000000..e69de29bb2 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 deleted file mode 100644 index ed9b9eaab9..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/PlanFactory.kt +++ /dev/null @@ -1,695 +0,0 @@ -package org.partiql.plan.builder - -import org.partiql.plan.AggregateCall -import org.partiql.plan.Collation -import org.partiql.plan.Exclusion -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.rel.RelCorrelate -import org.partiql.plan.rel.RelCorrelateImpl -import org.partiql.plan.rel.RelDistinct -import org.partiql.plan.rel.RelDistinctImpl -import org.partiql.plan.rel.RelExcept -import org.partiql.plan.rel.RelExceptImpl -import org.partiql.plan.rel.RelExclude -import org.partiql.plan.rel.RelExcludeImpl -import org.partiql.plan.rel.RelFilter -import org.partiql.plan.rel.RelFilterImpl -import org.partiql.plan.rel.RelIntersect -import org.partiql.plan.rel.RelIntersectImpl -import org.partiql.plan.rel.RelIterate -import org.partiql.plan.rel.RelIterateImpl -import org.partiql.plan.rel.RelJoin -import org.partiql.plan.rel.RelJoinImpl -import org.partiql.plan.rel.RelLimit -import org.partiql.plan.rel.RelLimitImpl -import org.partiql.plan.rel.RelOffset -import org.partiql.plan.rel.RelOffsetImpl -import org.partiql.plan.rel.RelProject -import org.partiql.plan.rel.RelProjectImpl -import org.partiql.plan.rel.RelScan -import org.partiql.plan.rel.RelScanImpl -import org.partiql.plan.rel.RelSort -import org.partiql.plan.rel.RelSortImpl -import org.partiql.plan.rel.RelType -import org.partiql.plan.rel.RelUnion -import org.partiql.plan.rel.RelUnionImpl -import org.partiql.plan.rel.RelUnpivot -import org.partiql.plan.rel.RelUnpivotImpl -import org.partiql.plan.rex.Rex -import org.partiql.plan.rex.RexArray -import org.partiql.plan.rex.RexArrayImpl -import org.partiql.plan.rex.RexBag -import org.partiql.plan.rex.RexBagImpl -import org.partiql.plan.rex.RexCall -import org.partiql.plan.rex.RexCallDynamic -import org.partiql.plan.rex.RexCallDynamicImpl -import org.partiql.plan.rex.RexCallImpl -import org.partiql.plan.rex.RexCase -import org.partiql.plan.rex.RexCaseImpl -import org.partiql.plan.rex.RexCast -import org.partiql.plan.rex.RexCastImpl -import org.partiql.plan.rex.RexCoalesce -import org.partiql.plan.rex.RexCoalesceImpl -import org.partiql.plan.rex.RexError -import org.partiql.plan.rex.RexErrorImpl -import org.partiql.plan.rex.RexLit -import org.partiql.plan.rex.RexLitImpl -import org.partiql.plan.rex.RexNullIf -import org.partiql.plan.rex.RexNullIfImpl -import org.partiql.plan.rex.RexPathIndex -import org.partiql.plan.rex.RexPathIndexImpl -import org.partiql.plan.rex.RexPathKey -import org.partiql.plan.rex.RexPathKeyImpl -import org.partiql.plan.rex.RexPathSymbol -import org.partiql.plan.rex.RexPathSymbolImpl -import org.partiql.plan.rex.RexPivot -import org.partiql.plan.rex.RexPivotImpl -import org.partiql.plan.rex.RexSelect -import org.partiql.plan.rex.RexSelectImpl -import org.partiql.plan.rex.RexSpread -import org.partiql.plan.rex.RexSpreadImpl -import org.partiql.plan.rex.RexStruct -import org.partiql.plan.rex.RexStructImpl -import org.partiql.plan.rex.RexSubquery -import org.partiql.plan.rex.RexSubqueryComp -import org.partiql.plan.rex.RexSubqueryCompImpl -import org.partiql.plan.rex.RexSubqueryImpl -import org.partiql.plan.rex.RexSubqueryIn -import org.partiql.plan.rex.RexSubqueryInImpl -import org.partiql.plan.rex.RexSubqueryTest -import org.partiql.plan.rex.RexSubqueryTestImpl -import org.partiql.plan.rex.RexTable -import org.partiql.plan.rex.RexTableImpl -import org.partiql.plan.rex.RexType -import org.partiql.plan.rex.RexVar -import org.partiql.plan.rex.RexVarImpl -import org.partiql.spi.catalog.Table -import org.partiql.spi.function.Aggregation -import org.partiql.spi.function.Function -import org.partiql.spi.value.Datum -import org.partiql.types.PType - -/** - * The [PlanFactory] factory is used by builders and readers to provide concrete implementations of plan interfaces. - * - * This is an interface with default implementations; we cannot use default values or @JvmOverloads. There are a handful - * of overloads where default values are inserted (such as set operator quantifiers) or where omission of certain fields - * changes the logical operator - */ -public interface PlanFactory { - - // ALL MEMBERS SHOULD BE @JvmStatic - public companion object { - - /** - * A singleton of the [PlanFactory] with all the default implementations. - */ - @JvmStatic - public val STANDARD: PlanFactory = object : PlanFactory {} - } - - // --- REL OPERATORS ------------------------------------------------------------------------------------------------ - - /** - * Create a [RelAggregate] instance. - * - * @param input - * @param calls [RelAggregateCall - * - * @param input - */ - public fun relAggregate( - input: Rel, - calls: List, - groups: List, - ): RelAggregate = RelAggregateImpl(input, calls, groups) - - /** - * Create a [AggregateCall] instance. - * - * @param aggregation - * @param args - * @param isDistinct - * @return - */ - public fun relAggregateCall( - aggregation: Aggregation, - args: List, - isDistinct: Boolean = false, - ): AggregateCall = RelAggregateCallImpl(aggregation, args, isDistinct) - - /** - * Create a [RelCorrelate] instance for a lateral cross join. - * - * @param lhs - * @param rhs - * @return - */ - public fun relCorrelate(lhs: Rel, rhs: Rel): RelCorrelate = relCorrelate(lhs, rhs, JoinType.INNER) - - /** - * Create a [RelCorrelate] instance for a lateral join. - * - * @param lhs - * @param rhs - * @param joinType - * @return - */ - public fun relCorrelate(lhs: Rel, rhs: Rel, joinType: JoinType): RelCorrelate = RelCorrelateImpl(lhs, rhs, joinType) - - /** - * Create a [RelDistinct] instance. - * - * @param input - * @return - */ - public fun relDistinct(input: Rel): RelDistinct = RelDistinctImpl(input) - - /** - * Create a [RelExcept] instance for the default EXCEPT. - * - * @param lhs - * @param rhs - * @return - */ - public fun relExcept(lhs: Rel, rhs: Rel): RelExcept = relExcept(lhs, rhs, false) - - /** - * Create a [RelExcept] instance for EXCEPT [ALL|DISTINCT]. - * - * @param lhs - * @param rhs - * @return - */ - public fun relExcept( - lhs: Rel, - rhs: Rel, - isAll: Boolean, - ): RelExcept = RelExceptImpl(lhs, rhs, isAll) - - /** - * Create a [RelExclude] instance. - * - * @param input - * @param exclusions - * @return - */ - public fun relExclude(input: Rel, exclusions: List): RelExclude = RelExcludeImpl(input, exclusions) - - /** - * Create a [RelFilter] instance. - * - * @param input - * @param predicate - * @return - */ - public fun relFilter(input: Rel, predicate: Rex): RelFilter = RelFilterImpl(input, predicate) - - /** - * Create a [RelIntersect] instance for the default INTERSECT. - * - * @param lhs - * @param rhs - * @return - */ - public fun relIntersect( - lhs: Rel, - rhs: Rel, - ): RelIntersect = relIntersect(lhs, rhs, false) - - /** - * Create a [RelIntersect] instance for INTERSECT [ALL|DISTINCT]. - * - * @param lhs - * @param rhs - * @return - */ - public fun relIntersect( - lhs: Rel, - rhs: Rel, - isAll: Boolean, - ): RelIntersect = RelIntersectImpl(lhs, rhs, isAll) - - /** - * Create a [RelIterate] instance. - * - * @param input - * @return - */ - public fun relIterate(input: Rex): RelIterate = RelIterateImpl(input) - - /** - * Create a [RelJoin] instance for a cross join. - * - * - , - * - CROSS JOIN - * - JOIN ON TRUE - * - * @param lhs - * @param rhs - * @return - */ - public fun relJoin(lhs: Rel, rhs: Rel): RelJoin = relJoin(lhs, rhs, condition = null, JoinType.INNER) - - /** - * Create a [RelJoin] instance. - * - * @param lhs - * @param rhs - * @param condition - * @param type - * @return - */ - public fun relJoin( - lhs: Rel, - rhs: Rel, - condition: Rex?, - type: JoinType, - lhsSchema: RelType? = null, - rhsSchema: RelType? = null, - ): RelJoin = RelJoinImpl(lhs, rhs, condition, type, lhsSchema, rhsSchema) - - /** - * Create a [RelLimit] instance. - * - * @param input - * @param limit - * @return - */ - public fun relLimit(input: Rel, limit: Rex): RelLimit = RelLimitImpl(input, limit) - - /** - * Create a [RelLimit] instance. - * - * @param input - * @param offset - * @return - */ - public fun relOffset(input: Rel, offset: Rex): RelOffset = RelOffsetImpl(input, offset) - - /** - * Create a [RelProject] instance. - * - * @param input - * @param projections - * @return - */ - public fun relProject(input: Rel, projections: List): RelProject = RelProjectImpl(input, projections) - - /** - * Create a [RelScan] instance. - * - * @param input - * @return - */ - public fun relScan(input: Rex): RelScan = RelScanImpl(input) - - /** - * Create a [RelSort] instance. - * - * @param input - * @param collations - * @return - */ - public fun relSort(input: Rel, collations: List): RelSort = RelSortImpl(input, collations) - - /** - * Create a [RelUnion] instance for the default UNION. - * - * @param lhs - * @param rhs - * @return - */ - public fun relUnion(lhs: Rel, rhs: Rel): RelUnion = relUnion(lhs, rhs, false) - - /** - * Create a [RelUnion] instance for UNION [ALL|DISTINCT]. - * - * @param lhs - * @param rhs - * @return - */ - public fun relUnion(lhs: Rel, rhs: Rel, isAll: Boolean): RelUnion = RelUnionImpl(lhs, rhs, isAll) - - /** - * Create a [RelUnpivot] instance. - * - * @param input - * @return - */ - public fun relUnpivot(input: Rex): RelUnpivot = RelUnpivotImpl(input) - - // --- REX OPERATORS ------------------------------------------------------------------------------------------------ - - /** - * Create a [RexArray] instance with dynamic array type. - * - * @param values - * @return - */ - public fun rexArray(values: Collection): RexArray = RexArrayImpl(values, RexType(PType.array())) - - /** - * Create a [RexArray] instance with the given array type. - * - * @param values - * @param type - * @return - */ - public fun rexArray(values: Collection, type: RexType): RexArray = RexArrayImpl(values, type) - - /** - * Create a [RexBag] instance with dynamic bag type. - * - * @param values - * @return - */ - public fun rexBag(values: Collection): RexBag = RexBagImpl(values, RexType(PType.bag())) - - /** - * Create a [RexBag] instance with the given array type. - * - * @param values - * @param type - * @return - */ - public fun rexBag(values: Collection, type: RexType): RexBag = RexBagImpl(values, type) - - /** - * Create a [RexCall] instance. - * - * @param function - * @param args - * @return - */ - public fun rexCall(function: Function.Instance, args: List): RexCall = RexCallImpl(function, args) - - /** - * Create a [RexCallDynamic] instance. - * - * @param name TODO - * @param functions TODO - * @param args TODO - * @return TODO - */ - public fun rexCallDynamic(name: String, functions: List, args: List): RexCallDynamic = - RexCallDynamicImpl(name, functions, args) - - /** - * Create a [RexCase] instance for a searched case-when with dynamic type. - * - * @param branches - * @param default - * @return - */ - public fun rexCase(branches: List, default: Rex?): RexCase = rexCase(null, branches, default) - - /** - * Create a [RexCase] instance for a searched case-when with the given type. - * - * @param branches - * @param default - * @param type - * @return - */ - public fun rexCase(branches: List, default: Rex?, type: RexType): RexCase = - rexCase(null, branches, default, type) - - /** - * Create a [RexCase] instance for a case-when with dynamic type. - * - * @param match - * @param branches - * @param default - * @return - */ - public fun rexCase(match: Rex?, branches: List, default: Rex?): RexCase = - RexCaseImpl(match, branches, default, RexType.dynamic()) - - /** - * Create a [RexCase] instance for a case-when with the given type. - * - * @param match - * @param branches - * @param default - * @param type - * @return - */ - public fun rexCase(match: Rex?, branches: List, default: Rex?, type: RexType): RexCase = - RexCaseImpl(match, branches, default, type) - - /** - * Create a [RexCast] instance. - * - * @param operand - * @param target - * @return - */ - public fun rexCast(operand: Rex, target: PType): RexCast = RexCastImpl(operand, target) - - /** - * Create a [RexCoalesce] instance with dynamic type. - * - * @param args - * @return - */ - public fun rexCoalesce(args: List): RexCoalesce = RexCoalesceImpl(args, RexType.dynamic()) - - /** - * Create a [RexCoalesce] instance with the given type. - * - * @param args - * @return - */ - public fun rexCoalesce(args: List, type: RexType): RexCoalesce = RexCoalesceImpl(args, type) - - /** - * Create a [RexVar] instance with dynamic type. - * - * @param depth - * @param offset - * @return - */ - public fun rexVar(depth: Int, offset: Int): RexVar = RexVarImpl(depth, offset, RexType.dynamic()) - - /** - * Create a [RexVar] instance with the given type. - * - * @param depth - * @param offset - * @param type - * @return - */ - public fun rexVar(depth: Int, offset: Int, type: RexType): RexVar = RexVarImpl(depth, offset, type) - - /** - * TODO AUDIT ME - * Create a [RexError] instance. - */ - public fun rexError(type: PType): RexError = RexErrorImpl() - - /** - * Create a [RexLit] instance. - * - * @param value - * @return - */ - public fun rexLit(value: Datum): RexLit = RexLitImpl(value) - - /** - * Create a [RexNullIf] instance. - */ - public fun rexNullIf(value: Rex, nullifier: Rex): RexNullIf = RexNullIfImpl(value, nullifier) - - /** - * Create a [RexPathIndex] instance with dynamic type. - * - * @param operand - * @param index - * @return - */ - public fun rexPathIndex(operand: Rex, index: Rex): RexPathIndex = - RexPathIndexImpl(operand, index, RexType.dynamic()) - - /** - * Create a [RexPathIndex] instance with the given type. - * - * @param operand - * @param index - * @param type - * @return - */ - public fun rexPathIndex(operand: Rex, index: Rex, type: RexType): RexPathIndex = - RexPathIndexImpl(operand, index, type) - - /** - * Create a [RexPathKey] instance with dynamic type. - * - * @param operand - * @param key - * @return - */ - public fun rexPathKey(operand: Rex, key: Rex): RexPathKey = RexPathKeyImpl(operand, key, RexType.dynamic()) - - /** - * Create a [RexPathKey] instance with the given type. - * - * @param operand - * @param key - * @param type - * @return - */ - public fun rexPathKey(operand: Rex, key: Rex, type: RexType): RexPathKey = RexPathKeyImpl(operand, key, type) - - /** - * Create a [RexPathSymbol] instance with dynamic type. - * - * @param operand - * @param symbol - * @return - */ - public fun rexPathSymbol(operand: Rex, symbol: String): RexPathSymbol = - RexPathSymbolImpl(operand, symbol, RexType.dynamic()) - - /** - * Create a [RexPathSymbol] instance with the given type. - * - * @param operand - * @param symbol - * @param type - * @return - */ - public fun rexPathSymbol(operand: Rex, symbol: String, type: RexType): RexPathSymbol = - RexPathSymbolImpl(operand, symbol, type) - - /** - * Create a [RexPivot] instance. - * - * @param input - * @param key - * @param value - * @return - */ - public fun rexPivot(input: Rel, key: Rex, value: Rex): RexPivot = RexPivotImpl(input, key, value) - - /** - * Create a [RexSelect] instance. - * - * @param input - * @param constructor - * @return - */ - public fun rexSelect(input: Rel, constructor: Rex): RexSelect = RexSelectImpl(input, constructor) - - /** - * Create a [RexSpread] instance with open struct type. - * - * @param args - * @return - */ - public fun rexSpread(args: List): RexSpread = RexSpreadImpl(args, RexType(PType.struct())) - - /** - * Create a [RexSpread] instance with the given type. - * - * @param args - * @return - */ - public fun rexSpread(args: List, type: RexType): RexSpread = RexSpreadImpl(args, type) - - /** - * Create a [RexStruct] instance with open struct type. - * - * @param fields - * @return - */ - public fun rexStruct(fields: List): RexStruct = RexStructImpl(fields, RexType(PType.struct())) - - /** - * Create a [RexStruct] instance with the given type. - * - * @param fields - * @return - */ - public fun rexStruct(fields: List, type: RexType): RexStruct = RexStructImpl(fields, type) - - /** - * Create a [RexSubquery] instance. - * - * TODO REMOVE constructor AND asScalar – TEMPORARY UNTIL SUBQUERIES ARE FIXED IN THE PLANNER. - * - * @param rel - * @return - */ - public fun rexSubquery(rel: Rel, constructor: Rex, asScalar: Boolean): RexSubquery = - RexSubqueryImpl(rel, constructor, asScalar) - - /** - * Create a [RexSubqueryComp] instance. - * - * @param args - * @param comp - * @param rel - * @return - */ - public fun rexSubqueryComp( - args: List, - comp: RexSubqueryComp.Comp, - rel: Rel, - ): RexSubqueryComp = RexSubqueryCompImpl(args, comp, null, rel) - - /** - * Create a [RexSubqueryComp] instance. - * - * @param args - * @param comp - * @param quantifier - * @param rel - * @return - */ - public fun rexSubqueryComp( - args: List, - comp: RexSubqueryComp.Comp, - quantifier: RexSubqueryComp.Quantifier?, - rel: Rel, - ): RexSubqueryComp = RexSubqueryCompImpl(args, comp, quantifier, rel) - - /** - * Create a [RexSubqueryIn] instance for single argument. - * - * @param arg - * @param rel - * @return - */ - public fun rexSubqueryIn(arg: Rex, rel: Rel): RexSubqueryIn = rexSubqueryIn(listOf(arg), rel) - - /** - * Create a [RexSubqueryIn] instance for a list argument. - * - * @param args - * @param rel - * @return - */ - public fun rexSubqueryIn(args: List, rel: Rel): RexSubqueryIn = RexSubqueryInImpl(args, rel) - - /** - * Create a [RexSubqueryTest] instance. - * - * @param test - * @param rel - * @return - */ - public fun rexSubqueryTest(test: RexSubqueryTest.Test, rel: Rel): RexSubqueryTest = RexSubqueryTestImpl(test, rel) - - /** - * Create a [RexTable] instance. - * - * @param table - * @return - */ - public fun rexTable(table: Table): RexTable = RexTableImpl(table) -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/RelBuilder.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/builder/RelBuilder.kt deleted file mode 100644 index 2fe7291b60..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/RelBuilder.kt +++ /dev/null @@ -1,240 +0,0 @@ -package org.partiql.plan.builder - -import org.partiql.plan.AggregateCall -import org.partiql.plan.Collation -import org.partiql.plan.Exclusion -import org.partiql.plan.JoinType -import org.partiql.plan.rel.Rel - -/** - * DataFrame style fluent-builder for PartiQL logical plans. - * - * TODO schemas and field names. - */ -@Suppress("LocalVariableName") -public class RelBuilder private constructor(builder: Builder) { - - // DO NOT USE FINAL MEMBERS - private var self: Builder = builder - - /** - * Invoke the builder with the default [PlanFactory] implementation. - */ - public fun build(): Rel = build(PlanFactory.STANDARD) - - /** - * Invoke the builder with the given [PlanFactory] implementation. - */ - public fun build(factory: PlanFactory): Rel = self.build(factory) - - /** - * This object holds named constructors for the [RelBuilder] class. - */ - public companion object { - - /** - * Initialize a logical scan operator builder. - */ - @JvmStatic - public fun scan(input: RexBuilder): RelBuilder = RelBuilder { - val _input = input.build(it) - it.relScan(_input) - } - - /** - * Initialize a logical iterate operator builder. - */ - @JvmStatic - public fun iterate(input: RexBuilder): RelBuilder = RelBuilder { - val _input = input.build(it) - it.relIterate(_input) - } - - /** - * Initialize a logical unpivot operator builder. - */ - @JvmStatic - public fun unpivot(input: RexBuilder): RelBuilder = RelBuilder { - val _input = input.build(it) - it.relUnpivot(_input) - } - } - - /** - * Appends a RelAggregate to the current operator builder. - */ - public fun aggregate( - calls: List, - groups: List, - ): RelBuilder = RelBuilder { - val _input = self.build(it) - val _calls = calls // TODO calls needs to be builder - val _groups = groups.map { group -> group.build(it) } - it.relAggregate(_input, _calls, _groups) - } - - public fun distinct(): RelBuilder = RelBuilder { - val _input = self.build(it) - it.relDistinct(_input) - } - - /** - * Appends a RelExcept to the current operator builder. - */ - public fun except(rhs: Rel): RelBuilder = RelBuilder { - val lhs = self.build(it) - it.relIntersect(lhs, rhs) - } - - /** - * Appends a RelExclude to the current operator builder. - */ - public fun exclude(exclusions: List): RelBuilder = RelBuilder { - val _input = self.build(it) - it.relExclude(_input, exclusions) - } - - /** - * Appends a RelFilter to the current operator builder. - */ - public fun filter(predicate: RexBuilder): RelBuilder = RelBuilder { - val _input = self.build(it) - val _predicate = predicate.build(it) - it.relFilter(_input, _predicate) - } - - /** - * Appends a RelIntersect to the current operator builder. - */ - public fun intersect(rhs: RelBuilder): RelBuilder = RelBuilder { - val _lhs = self.build(it) - val _rhs = rhs.build(it) - it.relIntersect(_lhs, _rhs) - } - - /** - * Appends a RelJoin to the current operator builder for LATERAL CROSS JOIN. - */ - public fun join(rhs: RelBuilder): RelBuilder = join(rhs, null, JoinType.INNER) - - /** - * Appends a RelJoin to the current operator builder for INNER JOIN ON . - * - * @param rhs - * @param condition - * @return - */ - public fun join( - rhs: RelBuilder, - condition: RexBuilder, - ): RelBuilder = join(rhs, condition, JoinType.INNER) - - /** - * Appends a RelJoin to the current operator builder for [LEFT|RIGHT|INNER|FULL] JOIN. - * - * @param rhs - * @param type - * @return - */ - public fun join(rhs: RelBuilder, type: JoinType): RelBuilder = join(rhs, null, type) - - /** - * Appends a RelJoin to the current operator builder for [LEFT|RIGHT|INNER|FULL] JOIN ON . - * - * @param rhs - * @param condition - * @param type - * @return - */ - public fun join( - rhs: RelBuilder, - condition: RexBuilder?, - type: JoinType, - ): RelBuilder = RelBuilder { - val _lhs = self.build(it) - val _rhs = rhs.build(it) - val _condition = condition?.build(it) - it.relJoin(_lhs, _rhs, _condition, type) - } - - /** - * Appends a RelLimit to the current operator builder. - * - * @param limit - * @return - */ - public fun limit(limit: RexBuilder): RelBuilder = RelBuilder { - val _input = self.build(it) - val _limit = limit.build(it) - it.relLimit(_input, _limit) - } - - /** - * Appends a RelOffset to the current operator builder. - * - * @param offset - * @return - */ - public fun offset(offset: RexBuilder): RelBuilder = RelBuilder { - val _input = self.build(it) - val _offset = offset.build(it) - it.relOffset(_input, _offset) - } - - /** - * Appends a RelProject to the current operator builder. - * - * @param projections - * @return - */ - public fun project(vararg projections: RexBuilder): RelBuilder = project(projections.toList()) - - /** - * Appends a RelProject to the current operator builder. - * - * @param projections - * @return - */ - public fun project(projections: List): RelBuilder = RelBuilder { - val _input = self.build(it) - val _projections = projections.map { rex -> rex.build(it) } - it.relProject(_input, _projections) - } - - /** - * Appends a RelSort to the current operator builder. - * - * @param collations - * @return - */ - public fun sort(collations: List): RelBuilder = RelBuilder { - val _input = self.build(it) - it.relSort(_input, collations) - } - - /** - * Appends a RelUnion to the current operator builder. - */ - public fun union(rhs: Rel): RelBuilder = RelBuilder { - val lhs = self.build(it) - it.relUnion(lhs, rhs) - } - - /** - * Appends a RexPivot to the current relational operator – this is a rel->rex projection. - */ - public fun pivot( - key: RexBuilder, - value: RexBuilder, - ): RexBuilder = RexBuilder.pivot(this, key, value) - - /** - * Appends a RexSelect to the current relation operator – this is a rel->rex projection. - */ - public fun select(constructor: RexBuilder): RexBuilder = RexBuilder.select(this, constructor) - - // PRIVATE FUNCTIONAL INTERFACE COMPILES DOWN TO PRIVATE STATIC METHODS. - private fun interface Builder { - fun build(factory: PlanFactory): Rel - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/RexBuilder.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/builder/RexBuilder.kt deleted file mode 100644 index be30e7897e..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/builder/RexBuilder.kt +++ /dev/null @@ -1,203 +0,0 @@ -package org.partiql.plan.builder - -import org.partiql.plan.rel.Rel -import org.partiql.plan.rex.Rex -import org.partiql.plan.rex.RexStruct -import org.partiql.plan.rex.RexSubqueryTest -import org.partiql.spi.catalog.Table -import org.partiql.spi.value.Datum -import org.partiql.types.PType - -/** - * DataFrame style fluent-builder for PartiQL logical plans. - */ -@Suppress("LocalVariableName") -public class RexBuilder private constructor(rex: Builder) { - - // DO NOT USE FINAL MEMBERS - private var self: Builder = rex - - /** - * Invoke the builder with the default [PlanFactory] implementation. - */ - public fun build(): Rex = build(PlanFactory.STANDARD) - - /** - * Invoke the builder with the given [PlanFactory] implementation. - */ - public fun build(factory: PlanFactory): Rex = self.build(factory) - - /** - * This object holds named constructors for the [RexBuilder] class. - */ - public companion object { - - @JvmStatic - public fun variable(offset: Int): RexBuilder = RexBuilder { - it.rexVar(0, offset) - } - - @JvmStatic - public fun variable(depth: Int, offset: Int): RexBuilder = RexBuilder { - it.rexVar(depth, offset) - } - - @JvmStatic - public fun table(table: Table): RexBuilder = RexBuilder { - it.rexTable(table) - } - - @JvmStatic - public fun lit(value: Boolean): RexBuilder = lit(Datum.bool(value)) - - @JvmStatic - public fun lit(value: Int): RexBuilder = lit(Datum.integer(value)) - - @JvmStatic - public fun lit(value: Long): RexBuilder = lit(Datum.bigint(value)) - - @JvmStatic - public fun lit(value: String): RexBuilder = lit(Datum.string(value)) - - @JvmStatic - public fun lit(value: Datum): RexBuilder = RexBuilder { it.rexLit(value) } - - @JvmStatic - public fun array(values: Collection): RexBuilder = RexBuilder { it.rexArray(values) } - - @JvmStatic - public fun bag(values: Collection): RexBuilder = RexBuilder { it.rexBag(values) } - - @JvmStatic - public fun coalesce(args: List): RexBuilder = RexBuilder { - it.rexCoalesce(args) - } - - /** - * TODO add some vararg and vararg pair overloads. - */ - @JvmStatic - public fun struct(fields: List): RexBuilder = RexBuilder { - it.rexStruct(fields) - } - - /** - * Spread because it's similar to the struct/dict spread of other languages. { x..., y... } - */ - @JvmStatic - public fun spread(args: List): RexBuilder = RexBuilder { - it.rexSpread(args) - } - - /** - * Scalar subquery coercion. - */ - @JvmStatic - public fun subquery(rel: RelBuilder): RexBuilder = RexBuilder { - throw UnsupportedOperationException("subquery builders are removed until supported in partiql-planner") - } - - /** - * Subquery EXISTS. - */ - @JvmStatic - public fun exists(rel: RelBuilder): RexBuilder = RexBuilder { - val _rel = rel.build(it) - it.rexSubqueryTest(RexSubqueryTest.Test.EXISTS, _rel) - } - - /** - * Subquery UNIQUE. - */ - @JvmStatic - public fun unique(rel: RelBuilder): RexBuilder = RexBuilder { - val _rel = rel.build(it) - it.rexSubqueryTest(RexSubqueryTest.Test.UNIQUE, _rel) - } - - /** - * Creates a RexPivot operator. - */ - @JvmStatic - public fun pivot(input: RelBuilder, key: RexBuilder, value: RexBuilder): RexBuilder = RexBuilder { - val _input = input.build(it) - val _key = key.build(it) - val _value = value.build(it) - it.rexPivot(_input, _key, _value) - } - - /** - * Creates a RexSelect operator. - * - * @param input - * @param constructor - * @return - */ - @JvmStatic - public fun select(input: RelBuilder, constructor: RexBuilder): RexBuilder = RexBuilder { - val _input = input.build(it) - val _constructor = constructor.build(it) - it.rexSelect(_input, _constructor) - } - } - - /** - * Appends a RexCast to the current rex builder. - */ - public fun cast(target: PType): RexBuilder = RexBuilder { - val _operand = self.build(it) - it.rexCast(_operand, target) - } - - /** - * Appends a RexPathKey (or RexPathSymbol) to the current rex builder. - * - * @param key - * @return - */ - public fun path(key: String, caseInsensitive: Boolean = false): RexBuilder = RexBuilder { - val _key = it.rexLit(Datum.string(key)) - val _operand = self.build(it) - if (caseInsensitive) { - it.rexPathSymbol(_operand, key) - } else { - it.rexPathKey(_operand, _key) - } - } - - /** - * Appends a RexPathIndex to the current rex builder. - * - * @param index - * @return - */ - public fun path(index: Int): RexBuilder = RexBuilder { - val _index = it.rexLit(Datum.integer(index)) - val _operand = self.build(it) - it.rexPathIndex(_operand, _index) - } - - /** - * Transform the [Rex] operator into a RelScan operator - this a rex->rel projection. - */ - public fun scan(): RelBuilder = RelBuilder.scan(this) - - /** - * Transform the [Rel] operator into a RelIterate operator – this is rex->rel projection. - * - * @return - */ - public fun iterate(): RelBuilder = RelBuilder.iterate(this) - - /** - * The UNPIVOT expression-to-relation projection. - */ - public fun unpivot(): RelBuilder = RelBuilder.unpivot(this) - - /** - * PRIVATE FUNCTIONAL INTERFACE COMPILES DOWN TO PRIVATE STATIC METHODS. - */ - private fun interface Builder { - fun build(factory: PlanFactory): Rex - } -} 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 55d3d9af86..0000000000 --- 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 4a0c0e550d..0000000000 --- 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 b8f51b2f49..0000000000 --- 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/RelDistinct.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelDistinct.kt deleted file mode 100644 index 77ae8a3b56..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelDistinct.kt +++ /dev/null @@ -1,54 +0,0 @@ -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. - */ -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() - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExcept.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExcept.kt deleted file mode 100644 index a74cb8a33e..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExcept.kt +++ /dev/null @@ -1,70 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExclude.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExclude.kt deleted file mode 100644 index 3e3522b5e5..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelExclude.kt +++ /dev/null @@ -1,59 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelFilter.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelFilter.kt deleted file mode 100644 index e76b86981d..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelFilter.kt +++ /dev/null @@ -1,68 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIntersect.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIntersect.kt deleted file mode 100644 index 4062ff6c45..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIntersect.kt +++ /dev/null @@ -1,70 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIterate.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIterate.kt deleted file mode 100644 index 15b6cc9a58..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelIterate.kt +++ /dev/null @@ -1,44 +0,0 @@ -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. - */ -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() - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelJoin.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelJoin.kt deleted file mode 100644 index 6846b08175..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelJoin.kt +++ /dev/null @@ -1,98 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelLimit.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelLimit.kt deleted file mode 100644 index ada7af34bf..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelLimit.kt +++ /dev/null @@ -1,57 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelOffset.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelOffset.kt deleted file mode 100644 index 5ab13454ff..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelOffset.kt +++ /dev/null @@ -1,57 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelProject.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelProject.kt deleted file mode 100644 index 3e50f26da5..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelProject.kt +++ /dev/null @@ -1,55 +0,0 @@ -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. - */ -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 - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelScan.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelScan.kt deleted file mode 100644 index 6c98ce1db0..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelScan.kt +++ /dev/null @@ -1,43 +0,0 @@ -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. - */ -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() - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelSort.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelSort.kt deleted file mode 100644 index 31ee8c8df4..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelSort.kt +++ /dev/null @@ -1,62 +0,0 @@ -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. - */ -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 - } -} 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 cd2a3da43f..0000000000 --- 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/RelUnion.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnion.kt deleted file mode 100644 index ecfb2dcfc2..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rel/RelUnion.kt +++ /dev/null @@ -1,69 +0,0 @@ -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. - */ -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 - } -} 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 d64278c9c6..0000000000 --- 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() - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/Rex.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/Rex.kt deleted file mode 100644 index df78b03fc6..0000000000 --- a/partiql-plan/src/main/kotlin/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/kotlin/org/partiql/plan/rex/RexArray.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexArray.kt deleted file mode 100644 index f979194d56..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexArray.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * TODO DOCUMENTATION - */ -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) -} - -/** - * Default [RexArray] operator for extension. - */ -internal class RexArrayImpl(values: Collection, type: RexType) : RexArray { - - // DO NOT USE FINAL - private var _values = values - private var _type = type - - override fun getValues(): Collection = _values - - override fun getChildren(): Collection = _values.toList() - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexArray) return false - if (_values != other.getValues()) return false - return true - } - - override fun hashCode(): Int = _values.hashCode() -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexBag.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexBag.kt deleted file mode 100644 index 7b2acba378..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexBag.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * TODO DOCUMENTATION - */ -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) -} - -/** - * Default [RexBag] operator for extension. - */ -internal class RexBagImpl(values: Collection, type: RexType) : RexBag { - - // DO NOT USE FINAL - private var _values = values - private var _type = type - - override fun getValues(): Collection = _values - - override fun getChildren(): Collection = _values - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexBag) return false - if (_values != other.getValues()) return false - return true - } - - override fun hashCode(): Int = _values.hashCode() -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCall.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCall.kt deleted file mode 100644 index bfe39ec06f..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCall.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.spi.function.Function - -/** - * Logical operator for a scalar function call. - */ -public interface RexCall : Rex { - - /** - * Returns the function to invoke. - */ - public fun getFunction(): Function.Instance - - /** - * Returns the list of function arguments. - */ - public fun getArgs(): List - - override fun getChildren(): Collection = getArgs() - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCall(this, ctx) -} - -/** - * Default [RexCall] implementation meant for extension. - */ -internal class RexCallImpl(function: Function.Instance, args: List) : RexCall { - - // DO NOT USE FINAL - private var _function: Function.Instance = function - private var _args: List = args - private var _type: RexType = RexType(function.returns) - - override fun getFunction(): Function.Instance = _function - - override fun getArgs(): List = _args - - override fun getType(): RexType = _type - - override fun getChildren(): Collection = _args -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCallDynamic.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCallDynamic.kt deleted file mode 100644 index 2c85dee791..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCallDynamic.kt +++ /dev/null @@ -1,54 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.spi.function.Function -import org.partiql.types.PType - -/** - * Logical operator for a dynamic dispatch call. - */ -public interface RexCallDynamic : Rex { - - /** - * Dynamic function name. - */ - public fun getName(): String - - /** - * Returns the functions to dispatch to. - */ - public fun getFunctions(): List - - /** - * Returns the list of function arguments. - */ - public fun getArgs(): List - - override fun getChildren(): Collection = getArgs() - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCallDynamic(this, ctx) -} - -/** - * Default [RexCallDynamic] implementation meant for extension. - */ -internal class RexCallDynamicImpl( - private var name: String, - private var functions: List, - private var args: List, - type: PType = PType.dynamic() -) : RexCallDynamic { - - // DO NOT USE FINAL - private var _type: RexType = RexType(type) - - override fun getName(): String = name - - override fun getFunctions(): List = functions - - override fun getArgs(): List = args - - override fun getType(): RexType = _type - - override fun getChildren(): Collection = args -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCase.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCase.kt deleted file mode 100644 index 4d6a665ba7..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCase.kt +++ /dev/null @@ -1,104 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * Representative of the simple CASE-WHEN. - */ -public interface RexCase : Rex { - - public fun getMatch(): Rex? - - public fun getBranches(): List - - public fun getDefault(): Rex? - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitCase(this, ctx) - - override fun getChildren(): Collection { - val children = mutableListOf() - val match = getMatch() - val branches = getBranches() - val default = getDefault() - if (match != null) { - children.add(match) - } - for (branch in branches) { - children.add(branch.getCondition()) - children.add(branch.getResult()) - } - if (default != null) { - children.add(default) - } - return children - } - - /** - * TODO DOCUMENTATION - */ - public interface Branch { - public fun getCondition(): Rex - public fun getResult(): Rex - } -} - -/** - * Internal implementation of [RexCase]. - */ -internal class RexCaseImpl(match: Rex?, branches: List, default: Rex?, type: RexType) : RexCase { - - // DO NOT USE FINAL - private var _match = match - private var _branches = branches - private var _default = default - private var _children: Collection? = null - private var _type = type - - override fun getMatch(): Rex? = _match - - override fun getBranches(): List = _branches - - override fun getDefault(): Rex? = _default - - override fun getChildren(): Collection { - if (_children == null) { - _children = super.getChildren() - } - return _children!! - } - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexCase) return false - if (_match != other.getMatch()) return false - if (_branches != other.getBranches()) return false - if (_default != other.getDefault()) return false - return true - } - - override fun hashCode(): Int { - var result = _match.hashCode() - result = 31 * result + _branches.hashCode() - result = 31 * result + _default.hashCode() - return result - } - - /** - * CASE-WHEN branch - * - * @param condition - * @param result - */ - internal class Branch(condition: Rex, result: Rex) : RexCase.Branch { - - // DO NOT USE FINAL - private var _condition = condition - private var _result = result - - override fun getCondition(): Rex = _condition - - override fun getResult(): Rex = _result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCast.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCast.kt deleted file mode 100644 index 96f21fb208..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCast.kt +++ /dev/null @@ -1,58 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.types.PType - -/** - * Logical `CAST` operator — ex: CAST( AS ). - */ -public interface RexCast : Rex { - - 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) -} - -/** - * Default [RexCast] implementation meant for extension. - */ -internal class RexCastImpl(operand: Rex, target: PType) : RexCast { - - // DO NOT USE FINAL - private var _operand = operand - private var _target = target - private var _children: List? = null - private var _type = RexType(_target) - - override fun getOperand(): Rex = _operand - - override fun getTarget(): PType = _target - - override fun getChildren(): Collection { - if (_children == null) { - _children = listOf(_operand) - } - return _children!! - } - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexCast) return false - if (_operand != other.getOperand()) return false - if (_target != other.getTarget()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _operand.hashCode() - result = 31 * result + _target.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCoalesce.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCoalesce.kt deleted file mode 100644 index aa7cef41ab..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexCoalesce.kt +++ /dev/null @@ -1,37 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * TODO DOCUMENTATION - */ -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) -} - -internal class RexCoalesceImpl(args: List, type: RexType) : RexCoalesce { - - // DO NOT USE FINAL - private var _args = args - private var _type = type - - override fun getArgs(): List = _args - - override fun getChildren(): Collection = _args - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexCoalesce) return false - if (_args != other.getArgs()) return false - return true - } - - override fun hashCode(): Int = _args.hashCode() -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexError.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexError.kt deleted file mode 100644 index b8c0186629..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexError.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.partiql.plan.rex - -/** - * This represents scenarios in which certain operations are statically known to fail in strict mode but return missing - * in permissive mode. - */ -import org.partiql.plan.Visitor - -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) -} - -internal class RexErrorImpl : RexError diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexLit.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexLit.kt deleted file mode 100644 index 954b0fe6df..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexLit.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.spi.value.Datum - -/** - * TODO DOCUMENTATION - */ -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) -} - -internal class RexLitImpl(value: Datum) : RexLit { - - // DO NOT USE FINAL - private var _value = value - private var _type = RexType(_value.type) - - override fun getValue(): Datum = _value - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexLit) return false - if (_value != other.getValue()) return false - return true - } - - override fun hashCode(): Int = _value.hashCode() -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexNullIf.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexNullIf.kt deleted file mode 100644 index 9f98216cbc..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexNullIf.kt +++ /dev/null @@ -1,49 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * Logical operator for the SQL NULLIF special form. - */ -public interface RexNullIf : Rex { - - 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) -} - -/** - * Internal - */ -internal class RexNullIfImpl(v1: Rex, v2: Rex) : RexNullIf { - - // DO NOT USE FINAL - private var _v1 = v1 - private var _v2 = v2 - - override fun getV1(): Rex = _v1 - - 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 - if (other !is RexNullIf) return false - if (_v1 != other.getV1()) return false - if (_v2 != other.getV2()) return false - return true - } - - override fun hashCode(): Int { - var result = _v1.hashCode() - result = 31 * result + _v2.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathIndex.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathIndex.kt deleted file mode 100644 index 926e1f0a78..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathIndex.kt +++ /dev/null @@ -1,34 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * Logical path index operator. - */ -public interface RexPathIndex : Rex { - - public fun getOperand(): Rex - - public fun getIndex(): Rex - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPathIndex(this, ctx) -} - -/** - * Standard internal implementation for [RexPathIndex]. - */ -internal class RexPathIndexImpl(operand: Rex, index: Rex, type: RexType) : RexPathIndex { - - // DO NOT USE FINAL - private var _operand = operand - private var _index = index - private var _type = type - - override fun getOperand() = _operand - - override fun getIndex() = _index - - override fun getType(): RexType = _type - - override fun getChildren(): Collection = listOf(_operand, _index) -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathKey.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathKey.kt deleted file mode 100644 index 97d27ddda8..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathKey.kt +++ /dev/null @@ -1,34 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * Logical operator for path lookup by key. - */ -public interface RexPathKey : Rex { - - public fun getOperand(): Rex - - public fun getKey(): Rex - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPathKey(this, ctx) -} - -/** - * Standard internal implementation for [RexPathKey]. - */ -internal class RexPathKeyImpl(operand: Rex, key: Rex, type: RexType) : RexPathKey { - - // DO NOT USE FINAL - private var _operand = operand - private var _key = key - private var _type = type - - override fun getOperand() = _operand - - override fun getKey() = _key - - override fun getType(): RexType = _type - - override fun getChildren(): Collection = listOf(_operand, _key) -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathSymbol.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathSymbol.kt deleted file mode 100644 index 2b4d400e7c..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPathSymbol.kt +++ /dev/null @@ -1,34 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * Logical operator for path lookup by symbol. - */ -public interface RexPathSymbol : Rex { - - public fun getOperand(): Rex - - public fun getSymbol(): String - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitPathSymbol(this, ctx) -} - -/** - * Standard internal implementation for [RexPathSymbol]. - */ -internal class RexPathSymbolImpl(operand: Rex, symbol: String, type: RexType) : RexPathSymbol { - - // DO NOT USE FINAL - private var _operand = operand - private var _symbol = symbol - private var _type = type - - override fun getOperand() = _operand - - override fun getSymbol() = _symbol - - override fun getType(): RexType = _type - - override fun getChildren(): Collection = listOf(_operand) -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPivot.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPivot.kt deleted file mode 100644 index 05c6bd9001..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexPivot.kt +++ /dev/null @@ -1,74 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.plan.rel.Rel -import org.partiql.types.PType - -/** - * TODO DOCUMENTATION - */ -public interface RexPivot : Rex { - - public fun getInput(): Rel - - 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) -} - -/** - * Default [RexPivot] operator. - */ -internal class RexPivotImpl(input: Rel, key: Rex, value: Rex) : RexPivot { - - // DO NOT USE FINAL - private var _input = input - private var _key = key - private var _value = value - - private var children: List? = null - private var type: PType? = null - - override fun getInput(): Rel = _input - - override fun getKey(): Rex = _key - - override fun getValue(): Rex = _value - - override fun getType(): RexType { - if (type == null) { - type = PType.struct() - } - return RexType(type!!) - } - - override fun getChildren(): Collection { - if (children == null) { - children = listOf(getKey(), getValue()) - } - return children!! - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexPivot) return false - - if (_input != other.getInput()) return false - if (_key != other.getKey()) return false - if (_value != other.getValue()) return false - - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _input.hashCode() - result = 31 * result + _key.hashCode() - result = 31 * result + _value.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSelect.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSelect.kt deleted file mode 100644 index 95096cc871..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSelect.kt +++ /dev/null @@ -1,59 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.plan.rel.Rel -import org.partiql.types.PType - -/** - * TODO DOCUMENTATION - */ -public interface RexSelect : Rex { - - 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) -} - -internal class RexSelectImpl(input: Rel, constructor: Rex) : RexSelect { - - private var _input = input - private var _constructor = constructor - private var _type: RexType? = null - - override fun getInput(): Rel = _input - - override fun getConstructor(): Rex = _constructor - - override fun getType(): RexType { - // compute type - if (_type == null) { - val e = _constructor.getType().getPType() - _type = if (_input.isOrdered()) { - RexType(PType.array(e)) - } else { - RexType(PType.bag(e)) - } - } - return _type!! - } - - override fun getChildren(): Collection = listOf(_constructor) - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexSelect) return false - if (_input != other.getInput()) return false - if (_constructor != other.getConstructor()) return false - return true - } - - override fun hashCode(): Int { - var result = _input.hashCode() - result = 31 * result + _constructor.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSpread.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSpread.kt deleted file mode 100644 index f4157f8c4c..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSpread.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * TODO DOCUMENTATION - */ -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) -} - -/** - * Default [RexSpread] operator intended for extension. - */ -internal class RexSpreadImpl(args: List, type: RexType) : RexSpread { - - // DO NOT USE FINAL - private var _args = args - private var _type = type - - override fun getArgs(): List = _args - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexSpreadImpl) return false - if (_args != other._args) return false - if (_type != other._type) return false - return true - } - - override fun hashCode(): Int { - var result = _args.hashCode() - result = 31 * result + _type.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexStruct.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexStruct.kt deleted file mode 100644 index 3ad4cfffc5..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexStruct.kt +++ /dev/null @@ -1,64 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * TODO DOCUMENTATION - */ -public interface RexStruct : Rex { - - public fun getFields(): List - - override fun getChildren(): Collection { - val children = mutableListOf() - for (field in getFields()) { - children.add(field.getKey()) - children.add(field.getValue()) - } - return children - } - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitStruct(this, ctx) - - /** - * TODO DOCUMENTATION - */ - public class Field( - private var key: Rex, - private var value: Rex, - ) { - public fun getKey(): Rex = key - public fun getValue(): Rex = value - } -} - -/** - * Default [RexStruct] implementation intended for extension. - */ -internal class RexStructImpl(fields: List, type: RexType) : RexStruct { - - // DO NOT USE FINAL - private var _fields = fields - private var _children: Collection? = null - private var _type = type - - override fun getFields(): List = _fields - - override fun getType(): RexType = _type - - override fun getChildren(): Collection { - if (_children == null) { - _children = super.getChildren() - } - return _children!! - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexStruct) return false - if (_fields != other.getFields()) return false - return true - } - - override fun hashCode(): Int = _fields.hashCode() -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubquery.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubquery.kt deleted file mode 100644 index 9d94538ea3..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubquery.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * Scalar subquery coercion. - */ -public interface RexSubquery : Rex { - - public fun getRel(): org.partiql.plan.rel.Rel - - // TODO REMOVE ME – TEMPORARY UNTIL PLANNER PROPERLY HANDLES SUBQUERIES - 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) -} - -/** - * Implementation of scalar subquery coercion. - */ -internal class RexSubqueryImpl(rel: org.partiql.plan.rel.Rel, constructor: Rex, asScalar: Boolean) : RexSubquery { - - // DO NOT USE FINAL - private var _rel = rel - private var _constructor = constructor - private var _asScalar = asScalar - - override fun getRel(): org.partiql.plan.rel.Rel = _rel - - override fun getConstructor(): Rex = _constructor - - override fun asScalar(): Boolean = _asScalar - - override fun getType(): RexType { - TODO("Not yet implemented") - } - - override fun getChildren(): Collection { - TODO("Not yet implemented") - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexSubquery) return false - if (_rel != other.getRel()) return false - return true - } - - override fun hashCode(): Int { - return _rel.hashCode() - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryComp.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryComp.kt deleted file mode 100644 index 7d9ae0093a..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryComp.kt +++ /dev/null @@ -1,85 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.plan.rel.Rel -import org.partiql.plan.rex.RexSubqueryComp.Comp -import org.partiql.plan.rex.RexSubqueryComp.Quantifier - -/** - * Logical operator for SQL subquery comparisons. - * - * - for subqueries. - * - . - */ -public interface RexSubqueryComp : Rex { - - public fun getArgs(): List - - public fun getComp(): Comp - - public fun getQuantifier(): Quantifier? - - public fun getRel(): Rel - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubqueryComp(this, ctx) - - /** - * SQL for use in the . - * - * TODO transition to 1.0 enums. - */ - public enum class Comp { - EQ, - NE, - LT, - LE, - GT, - GE, - OTHER; - } - - /** - * SQL for use in the . - * - * TODO transition to 1.0 enums. - */ - public enum class Quantifier { - ANY, - ALL, - SOME, - OTHER; - } -} - -/** - * Logical operator for SQL subquery comparisons. - * - * - for subqueries. - * - . - */ -internal class RexSubqueryCompImpl( - args: List, - comp: Comp, - quantifier: Quantifier?, - rel: Rel, -) : RexSubqueryComp { - - private var _args = args - private var _comp = comp - private var _quantifier = quantifier - private var _rel = rel - - override fun getType(): RexType = TODO("Not yet implemented") - - override fun getArgs(): List = _args - - override fun getComp(): Comp = _comp - - 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/kotlin/org/partiql/plan/rex/RexSubqueryIn.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryIn.kt deleted file mode 100644 index c742274a07..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryIn.kt +++ /dev/null @@ -1,35 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.plan.rel.Rel - -public interface RexSubqueryIn : Rex { - - public fun getArgs(): List - - public fun getRel(): Rel - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubqueryIn(this, ctx) -} - -/** - * Logical operator for SQL subquery comparisons. - * - * - for subqueries. - * - . - */ -internal class RexSubqueryInImpl(args: List, rel: Rel) : RexSubqueryIn { - - private var _args = args - private var _rel = rel - - override fun getType(): RexType = TODO("Not yet implemented") - - 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/kotlin/org/partiql/plan/rex/RexSubqueryTest.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryTest.kt deleted file mode 100644 index 9ad2ab6bd3..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexSubqueryTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.plan.rex.RexSubqueryTest.Test - -/** - * Logical expression for subquery tests EXISTS and UNIQUE. - * - * - "Specify a test for a non-empty set." - * - "Specify a test for the absence of duplicate rows." - */ -public interface RexSubqueryTest : Rex { - - public fun getTest(): Test - - public fun getRel(): org.partiql.plan.rel.Rel - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitSubqueryTest(this, ctx) - - /** - * EXISTS and UNIQUE are defined by SQL. - * - * TODO use 1.0 enum modeling. - */ - public enum class Test { - EXISTS, - UNIQUE, - OTHER; - } -} - -/** - * Logical operator for SQL subquery comparisons. - * - * - for subqueries. - * - . - */ -internal class RexSubqueryTestImpl(test: Test, rel: org.partiql.plan.rel.Rel) : RexSubqueryTest { - - private var _test = test - private var _rel = rel - - override fun getType(): RexType { - TODO("Not yet implemented") - } - - 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/kotlin/org/partiql/plan/rex/RexTable.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexTable.kt deleted file mode 100644 index 8bef45722b..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexTable.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor -import org.partiql.spi.catalog.Table - -/** - * Global variable references e.g. tables and views. - */ -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) -} - -/** - * Default [RexTable] implementation. - */ -internal class RexTableImpl(table: Table) : RexTable { - - // DO NOT USE FINAL - private var _table = table - private var _type = RexType(table.getSchema()) - - override fun getTable(): Table = _table - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexTable) return false - if (_table != other.getTable()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _table.hashCode() - return result - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexType.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexType.kt deleted file mode 100644 index b2f2dc9cf9..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexType.kt +++ /dev/null @@ -1,32 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.types.PType - -/** - * [RexType] is a simple wrapper over [PType], but does not necessarily only hold a PType. - * - * - * Developer Note: In later releases, a [RexType] may hold metadata to aid custom planner implementations. - */ -public class RexType public constructor(type: PType) { - - // PRIVATE VAR - private var _type: PType = type - - public fun getPType(): PType = _type - - override fun equals(other: Any?): Boolean = _type == other - - override fun hashCode(): Int = _type.hashCode() - - override fun toString(): String = _type.toString() - - public companion object { - - /** - * A [RexType] for an "untyped" logical plan node. - */ - @JvmStatic - public fun dynamic(): RexType = RexType(PType.dynamic()) - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexVar.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexVar.kt deleted file mode 100644 index 709626dc37..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/rex/RexVar.kt +++ /dev/null @@ -1,56 +0,0 @@ -package org.partiql.plan.rex - -import org.partiql.plan.Visitor - -/** - * TODO DOCUMENTATION - * TODO NAMING?? - */ -public interface RexVar : Rex { - - /** - * 0-indexed scope offset. - */ - public fun getDepth(): Int - - /** - * 0-index tuple offset. - */ - public fun getOffset(): Int - - override fun getChildren(): Collection = emptyList() - - override fun accept(visitor: Visitor, ctx: C): R = visitor.visitVar(this, ctx) -} - -/** - * Default [RexVar] implementation intended for extension. - */ -internal class RexVarImpl(depth: Int, offset: Int, type: RexType) : RexVar { - - // DO NOT USE FINAL - private var _depth = depth - private var _offset = offset - private var _type = type - - override fun getDepth(): Int = _depth - - override fun getOffset(): Int = _offset - - override fun getType(): RexType = _type - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is RexVar) return false - if (_depth != other.getDepth()) return false - if (_offset != other.getOffset()) return false - return true - } - - override fun hashCode(): Int { - var result = 1 - result = 31 * result + _depth - result = 31 * result + _offset - return result - } -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/SqlPlanner.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/SqlPlanner.kt index b0de20d8ea..abef56a6a8 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/SqlPlanner.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/SqlPlanner.kt @@ -1,11 +1,11 @@ package org.partiql.planner.internal import org.partiql.ast.Statement -import org.partiql.plan.Operation +import org.partiql.plan.Action +import org.partiql.plan.Operators import org.partiql.plan.Plan -import org.partiql.plan.builder.PlanFactory -import org.partiql.plan.rex.Rex import org.partiql.planner.PartiQLPlanner +import org.partiql.planner.PartiQLPlanner.Result import org.partiql.planner.PartiQLPlannerPass import org.partiql.planner.internal.normalize.normalize import org.partiql.planner.internal.transforms.AstToPlan @@ -26,11 +26,10 @@ internal class SqlPlanner( private var flags: Set, ) : PartiQLPlanner { - public override fun plan( - statement: Statement, - session: Session, - ctx: Context, - ): PartiQLPlanner.Result { + /** + * Then default planner logic. + */ + override fun plan(statement: Statement, session: Session, ctx: Context): Result { try { // 0. Initialize the planning environment val env = Env(session) @@ -47,28 +46,31 @@ internal class SqlPlanner( val internal = org.partiql.planner.internal.ir.PartiQLPlan(typed) // 4. Assert plan has been resolved — translating to public API - var plan = PlanTransform(flags).transform(internal, ctx.getErrorListener()) + var plan = PlanTransform(flags).transform(internal, ctx.errorListener) // 5. Apply all passes for (pass in passes) { plan = pass.apply(plan, ctx) } - return PartiQLPlanner.Result(plan) + return Result(plan) } catch (e: PErrorListenerException) { throw e } catch (t: Throwable) { - val error = PError.INTERNAL_ERROR(PErrorKind.SEMANTIC(), null, t) - ctx.errorListener.report(error) - val plan = object : Plan { - override fun getOperation(): Operation { - return object : Operation.Query { - override fun getRex(): Rex { - return PlanFactory.STANDARD.rexError(PType.dynamic()) - } - } - } - } - return PartiQLPlanner.Result(plan) + return catchAll(ctx, t) } } + + /** + * Create a plan with a query action and error node. + * + * @param t + * @return + */ + private fun catchAll(ctx: Context, t: Throwable): Result { + val error = PError.INTERNAL_ERROR(PErrorKind.SEMANTIC(), null, t) + ctx.errorListener.report(error) + val query = Action.Query { Operators.STANDARD.error(PType.dynamic()) } + val plan = Plan { query } + return Result(plan) + } } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt index e52aea3c97..8d1537e38b 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt @@ -1,10 +1,12 @@ package org.partiql.planner.internal.transforms -import org.partiql.plan.AggregateCall +import org.partiql.plan.Action import org.partiql.plan.Collation import org.partiql.plan.Exclusion import org.partiql.plan.JoinType +import org.partiql.plan.Operators import org.partiql.plan.Plan +import org.partiql.plan.rel.RelAggregate import org.partiql.plan.rel.RelType import org.partiql.plan.rex.Rex import org.partiql.plan.rex.RexCase @@ -12,6 +14,7 @@ import org.partiql.plan.rex.RexStruct import org.partiql.plan.rex.RexType import org.partiql.plan.rex.RexVar import org.partiql.planner.internal.PlannerFlag +import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.SetQuantifier import org.partiql.planner.internal.ir.visitor.PlanBaseVisitor import org.partiql.spi.errors.PErrorListener @@ -45,12 +48,9 @@ internal class PlanTransform(private val flags: Set) { val query = (internal.statement as IStatement.Query) val visitor = Visitor(listener, signal) val root = visitor.visitRex(query.root, query.root.type) + val action = Action.Query { root } // TODO replace with standard implementations (or just remove plan transform altogether when possible). - return object : Plan { - override fun getOperation(): org.partiql.plan.Operation = object : org.partiql.plan.Operation.Query { - override fun getRex(): Rex = root - } - } + return Plan { action } } private class Visitor( @@ -58,7 +58,7 @@ internal class PlanTransform(private val flags: Set) { private val signal: Boolean, ) : PlanBaseVisitor() { - private val factory = org.partiql.plan.builder.PlanFactory.STANDARD + private val operators = Operators.STANDARD override fun defaultReturn(node: INode, ctx: PType): Any { TODO("Translation not supported for ${node::class.simpleName}") @@ -79,31 +79,34 @@ internal class PlanTransform(private val flags: Set) { */ override fun visitRexOpErr(node: IRex.Op.Err, ctx: PType): Any { // Listener should have already received the error/warning. The listener should have already failed compilation. - return factory.rexError(ctx) + return operators.error(ctx) } override fun visitRelOpErr(node: org.partiql.planner.internal.ir.Rel.Op.Err, ctx: PType): Any { // Listener should have already received the error. This node is a dud. Registered error listeners should // have failed compilation already. - return factory.relScan(factory.rexError(ctx)) + return operators.scan(operators.error(ctx)) } // EXPRESSIONS - override fun visitRex(node: IRex, ctx: PType): Rex = super.visitRexOp(node.op, node.type) as Rex + override fun visitRex(node: IRex, ctx: PType): Rex { + val o = visitRexOp(node.op, node.type) + o.type = RexType.of(ctx) + return o + } override fun visitRexOp(node: IRex.Op, ctx: PType): Rex = super.visitRexOp(node, ctx) as Rex override fun visitRexOpTupleUnion(node: IRex.Op.TupleUnion, ctx: PType): Any { val args = node.args.map { visitRex(it, ctx) } - val type = RexType(ctx) - return factory.rexSpread(args, type) + return operators.spread(args) } override fun visitRexOpSelect(node: IRex.Op.Select, ctx: PType): Any { val input = visitRel(node.rel, ctx) val constructor = visitRex(node.constructor, ctx) - return factory.rexSelect(input, constructor) + return operators.select(input, constructor) } /** @@ -117,49 +120,45 @@ internal class PlanTransform(private val flags: Set) { val input = visitRel(node.rel, ctx) val constructor = visitRex(node.constructor, ctx) val isScalar = node.coercion == IRex.Op.Subquery.Coercion.SCALAR - return factory.rexSubquery(input, constructor, isScalar) + return operators.subquery(input, constructor, isScalar) } override fun visitRexOpPivot(node: IRex.Op.Pivot, ctx: PType): Any { val input = visitRel(node.rel, ctx) val key = visitRex(node.key, ctx) val value = visitRex(node.value, ctx) - return factory.rexPivot(input, key, value) + return operators.pivot(input, key, value) } override fun visitRexOpStruct(node: IRex.Op.Struct, ctx: PType): Any { val fields = node.fields.map { field(it) } - val type = RexType(ctx) - return factory.rexStruct(fields, type) + return operators.struct(fields) } override fun visitRexOpCollection(node: IRex.Op.Collection, ctx: PType): Any { val values = node.values.map { visitRex(it, ctx) } - val type = RexType(ctx) return when (ctx.code()) { - PType.ARRAY -> factory.rexArray(values, type) - PType.BAG -> factory.rexBag(values, type) + PType.ARRAY -> operators.array(values) + PType.BAG -> operators.bag(values) else -> error("Expected bag or array, found ${ctx.name().lowercase()}") } } override fun visitRexOpCoalesce(node: IRex.Op.Coalesce, ctx: PType): Any { val args = node.args.map { visitRex(it, ctx) } - val type = RexType(ctx) - return factory.rexCoalesce(args, type) + return operators.coalesce(args) } override fun visitRexOpNullif(node: IRex.Op.Nullif, ctx: PType): Any { val value = visitRex(node.value, ctx) val nullifier = visitRex(node.nullifier, ctx) - return factory.rexNullIf(value, nullifier) + return operators.nullIf(value, nullifier) } override fun visitRexOpCase(node: IRex.Op.Case, ctx: PType): Any { val branches = node.branches.map { branch(it) } val default = visitRex(node.default, ctx) - val type = RexType(ctx) - return factory.rexCase(branches, default, type) + return operators.caseWhen(null, branches, default) } override fun visitRexOpCallDynamic(node: IRex.Op.Call.Dynamic, ctx: PType): Any { @@ -167,13 +166,13 @@ internal class PlanTransform(private val flags: Set) { val args = node.args.map { visitRex(it, ctx) } val fns = node.candidates.map { it.fn.signature } val name = node.candidates.first().fn.name.getName() - return factory.rexCallDynamic(name, fns, args) + return operators.dispatch(name, fns, args) } override fun visitRexOpCallStatic(node: IRex.Op.Call.Static, ctx: PType): Any { val fn = node.fn val args = node.args.map { visitRex(it, ctx) } - return factory.rexCall(fn, args) + return operators.call(fn, args) } override fun visitRexOpCallUnresolved(node: IRex.Op.Call.Unresolved, ctx: PType): Any { @@ -187,32 +186,29 @@ internal class PlanTransform(private val flags: Set) { override fun visitRexOpCastResolved(node: IRex.Op.Cast.Resolved, ctx: PType): Any { val operand = visitRex(node.arg, ctx) val target = node.cast.target - return factory.rexCast(operand, target) + return operators.cast(operand, target) } override fun visitRexOpPathSymbol(node: IRex.Op.Path.Symbol, ctx: PType): Any { val operand = visitRex(node.root, ctx) val symbol = node.key - val type = RexType(ctx) - return factory.rexPathSymbol(operand, symbol, type) + return operators.pathSymbol(operand, symbol) } override fun visitRexOpPathKey(node: IRex.Op.Path.Key, ctx: PType): Any { val operand = visitRex(node.root, ctx) val key = visitRex(node.key, ctx) - val type = RexType(ctx) - return factory.rexPathKey(operand, key, type) + return operators.pathKey(operand, key) } override fun visitRexOpPathIndex(node: IRex.Op.Path.Index, ctx: PType): Any { val operand = visitRex(node.root, ctx) val index = visitRex(node.key, ctx) - val type = RexType(ctx) - return factory.rexPathIndex(operand, index, type) + return operators.pathIndex(operand, index) } override fun visitRexOpVarGlobal(node: IRex.Op.Var.Global, ctx: PType): Any { - return factory.rexTable(node.ref.table) + return operators.table(node.ref.table) } override fun visitRexOpVarUnresolved(node: IRex.Op.Var.Unresolved, ctx: PType): Any { @@ -220,11 +216,9 @@ internal class PlanTransform(private val flags: Set) { } override fun visitRexOpVarLocal(node: IRex.Op.Var.Local, ctx: PType): Any { - return factory.rexVar( - depth = node.depth, - offset = node.ref, - type = RexType(ctx), - ) + val depth = node.depth + val offset = node.ref + return operators.variable(depth, offset, ctx) } @OptIn(PartiQLValueExperimental::class) @@ -234,24 +228,31 @@ internal class PlanTransform(private val flags: Set) { // PartiQLValue. if (value is DecimalValue && ctx.code() == PType.DECIMAL) { return when (val dec = value.value) { - null -> factory.rexLit(Datum.nullValue(ctx)) - else -> factory.rexLit(Datum.decimal(dec, ctx.precision, ctx.scale)) + null -> operators.lit(Datum.nullValue(ctx)) + else -> operators.lit(Datum.decimal(dec, ctx.precision, ctx.scale)) } } - return factory.rexLit(Datum.of(node.value)) + return operators.lit(Datum.of(node.value)) } // RELATION OPERATORS - override fun visitRel(node: IRel, ctx: PType): org.partiql.plan.rel.Rel = super.visitRelOp(node.op, ctx) as org.partiql.plan.rel.Rel + override fun visitRel(node: IRel, ctx: PType): org.partiql.plan.rel.Rel { + val o = visitRelOp(node.op, ctx) + val fields = node.type.schema.map { Field.of(it.name, it.type) }.toTypedArray() + val properties = if (node.type.props.contains(Rel.Prop.ORDERED)) RelType.ORDERED else 0 + o.type = RelType.of(fields, properties) + return o + } - override fun visitRelOp(node: IRel.Op, ctx: PType): org.partiql.plan.rel.Rel = super.visitRelOp(node, ctx) as org.partiql.plan.rel.Rel + override fun visitRelOp(node: IRel.Op, ctx: PType): org.partiql.plan.rel.Rel = + super.visitRelOp(node, ctx) as org.partiql.plan.rel.Rel override fun visitRelOpAggregate(node: IRel.Op.Aggregate, ctx: PType): Any { val input = visitRel(node.input, ctx) - val calls = node.calls.map { visitRelOpAggregateCall(it, ctx) as AggregateCall } + val calls = node.calls.map { visitRelOpAggregateCall(it, ctx) as RelAggregate.Measure } val groups = node.groups.map { visitRex(it, ctx) } - return factory.relAggregate(input, calls, groups) + return operators.aggregate(input, calls, groups) } override fun visitRelOpAggregateCallUnresolved(node: IRel.Op.Aggregate.Call.Unresolved, ctx: PType): Any { @@ -262,7 +263,7 @@ internal class PlanTransform(private val flags: Set) { val agg = node.agg.signature val args = node.args.map { visitRex(it, ctx) } val isDistinct = node.setq == SetQuantifier.DISTINCT - return factory.relAggregateCall(agg, args, isDistinct) + return RelAggregate.measure(agg, args, isDistinct) } override fun visitRelOpJoin(node: IRel.Op.Join, ctx: PType): Any { @@ -270,23 +271,19 @@ internal class PlanTransform(private val flags: Set) { val rhs = visitRel(node.rhs, ctx) val condition = visitRex(node.rex, ctx) - // TODO CLEANUP JOIN SCHEMA - val lhsType = toSchema(node.lhs.type) - val rhsType = toSchema(node.rhs.type) - - val type = when (node.type) { - IRel.Op.Join.Type.INNER -> JoinType.INNER - IRel.Op.Join.Type.LEFT -> JoinType.LEFT - IRel.Op.Join.Type.RIGHT -> JoinType.RIGHT - IRel.Op.Join.Type.FULL -> JoinType.FULL + val joinType = when (node.type) { + IRel.Op.Join.Type.INNER -> JoinType.INNER() + IRel.Op.Join.Type.LEFT -> JoinType.LEFT() + IRel.Op.Join.Type.RIGHT -> JoinType.RIGHT() + IRel.Op.Join.Type.FULL -> JoinType.FULL() } - return factory.relJoin(lhs, rhs, condition, type, lhsType, rhsType) + return operators.join(lhs, rhs, condition, joinType) } override fun visitRelOpExclude(node: IRel.Op.Exclude, ctx: PType): Any { val input = visitRel(node.input, ctx) val paths = node.paths.mapNotNull { visitRelOpExcludePath(it, ctx) } - return factory.relExclude(input, paths) + return operators.exclude(input, paths) } override fun visitRelOpExcludePath(node: IRel.Op.Exclude.Path, ctx: PType): Exclusion? { @@ -309,72 +306,72 @@ internal class PlanTransform(private val flags: Set) { override fun visitRelOpProject(node: IRel.Op.Project, ctx: PType): Any { val input = visitRel(node.input, ctx) val projections = node.projections.map { visitRex(it, ctx) } - return factory.relProject(input, projections) + return operators.project(input, projections) } override fun visitRelOpOffset(node: IRel.Op.Offset, ctx: PType): Any { val input = visitRel(node.input, ctx) val offset = visitRex(node.offset, ctx) - return factory.relOffset(input, offset) + return operators.offset(input, offset) } override fun visitRelOpLimit(node: IRel.Op.Limit, ctx: PType): Any { val input = visitRel(node.input, ctx) val limit = visitRex(node.limit, ctx) - return factory.relLimit(input, limit) + return operators.limit(input, limit) } override fun visitRelOpIntersect(node: IRel.Op.Intersect, ctx: PType): Any { val lhs = visitRel(node.lhs, ctx) val rhs = visitRel(node.rhs, ctx) val isAll = node.setq == SetQuantifier.ALL - return factory.relIntersect(lhs, rhs, isAll) + return operators.intersect(lhs, rhs, isAll) } override fun visitRelOpUnion(node: IRel.Op.Union, ctx: PType): Any { val lhs = visitRel(node.lhs, ctx) val rhs = visitRel(node.rhs, ctx) val isAll = node.setq == SetQuantifier.ALL - return factory.relUnion(lhs, rhs, isAll) + return operators.union(lhs, rhs, isAll) } override fun visitRelOpExcept(node: IRel.Op.Except, ctx: PType): Any { val lhs = visitRel(node.lhs, ctx) val rhs = visitRel(node.rhs, ctx) val isAll = node.setq == SetQuantifier.ALL - return factory.relExcept(lhs, rhs, isAll) + return operators.except(lhs, rhs, isAll) } override fun visitRelOpSort(node: IRel.Op.Sort, ctx: PType): Any { val input = visitRel(node.input, ctx) val collations = node.specs.map { collation(it) } - return factory.relSort(input, collations) + return operators.sort(input, collations) } override fun visitRelOpFilter(node: IRel.Op.Filter, ctx: PType): Any { val input = visitRel(node.input, ctx) val condition = visitRex(node.predicate, ctx) - return factory.relFilter(input, condition) + return operators.filter(input, condition) } override fun visitRelOpDistinct(node: IRel.Op.Distinct, ctx: PType): Any { val input = visitRel(node.input, ctx) - return factory.relDistinct(input) + return operators.distinct(input) } override fun visitRelOpUnpivot(node: IRel.Op.Unpivot, ctx: PType): Any { val input = visitRex(node.rex, ctx) - return factory.relUnpivot(input) + return operators.unpivot(input) } override fun visitRelOpScanIndexed(node: IRel.Op.ScanIndexed, ctx: PType): Any { val input = visitRex(node.rex, ctx) - return factory.relIterate(input) + return operators.iterate(input) } override fun visitRelOpScan(node: IRel.Op.Scan, ctx: PType): Any { val input = visitRex(node.rex, ctx) - return factory.relScan(input) + return operators.scan(input) } // HELPERS @@ -385,13 +382,13 @@ internal class PlanTransform(private val flags: Set) { private fun collation(spec: IRel.Op.Sort.Spec): Collation { val rex = visitRex(spec.rex, spec.rex.type) val (order, nulls) = when (spec.order) { - IRel.Op.Sort.Order.ASC_NULLS_LAST -> Collation.Order.ASC to Collation.Nulls.LAST - IRel.Op.Sort.Order.ASC_NULLS_FIRST -> Collation.Order.ASC to Collation.Nulls.FIRST - IRel.Op.Sort.Order.DESC_NULLS_LAST -> Collation.Order.DESC to Collation.Nulls.LAST - IRel.Op.Sort.Order.DESC_NULLS_FIRST -> Collation.Order.DESC to Collation.Nulls.FIRST + IRel.Op.Sort.Order.ASC_NULLS_LAST -> Collation.Order.ASC() to Collation.Nulls.LAST() + IRel.Op.Sort.Order.ASC_NULLS_FIRST -> Collation.Order.ASC() to Collation.Nulls.FIRST() + IRel.Op.Sort.Order.DESC_NULLS_LAST -> Collation.Order.DESC() to Collation.Nulls.LAST() + IRel.Op.Sort.Order.DESC_NULLS_FIRST -> Collation.Order.DESC() to Collation.Nulls.FIRST() } return object : Collation { - override fun getRex(): Rex = rex + override fun getColumn(): Rex = rex override fun getOrder(): Collation.Order = order override fun getNulls(): Collation.Nulls = nulls } @@ -400,25 +397,13 @@ internal class PlanTransform(private val flags: Set) { private fun field(field: IRex.Op.Struct.Field): RexStruct.Field { val key = visitRex(field.k, field.k.type) val value = visitRex(field.v, field.v.type) - return RexStruct.Field(key, value) + return RexStruct.field(key, value) } private fun branch(branch: IRex.Op.Case.Branch): RexCase.Branch { val condition = visitRex(branch.condition, branch.condition.type) val result = visitRex(branch.rex, branch.rex.type) - return object : RexCase.Branch { - override fun getCondition(): Rex = condition - override fun getResult(): Rex = result - } - } - - /** - * TODO TEMPORARY! - */ - private fun toSchema(type: IRel.Type): RelType = object : RelType { - private val fields = type.schema.map { Field.of(it.name, it.type) } - override fun getFields(): List = fields - override fun getField(name: String): Field = fields.first { it.name == name } + return RexCase.branch(condition, result) } } } diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanEquivalenceVisitor.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanEquivalenceOperatorVisitor.kt similarity index 91% rename from partiql-planner/src/test/kotlin/org/partiql/planner/PlanEquivalenceVisitor.kt rename to partiql-planner/src/test/kotlin/org/partiql/planner/PlanEquivalenceOperatorVisitor.kt index a2013587e5..bbb5535e30 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanEquivalenceVisitor.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanEquivalenceOperatorVisitor.kt @@ -1,11 +1,9 @@ -@file:Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") - package org.partiql.planner -import org.partiql.plan.Operation +import org.partiql.plan.Action import org.partiql.plan.Operator +import org.partiql.plan.OperatorVisitor import org.partiql.plan.Plan -import org.partiql.plan.Visitor import org.partiql.plan.rel.RelAggregate import org.partiql.plan.rel.RelCorrelate import org.partiql.plan.rel.RelDistinct @@ -25,10 +23,10 @@ import org.partiql.plan.rel.RelUnpivot import org.partiql.plan.rex.RexArray import org.partiql.plan.rex.RexBag import org.partiql.plan.rex.RexCall -import org.partiql.plan.rex.RexCallDynamic import org.partiql.plan.rex.RexCase import org.partiql.plan.rex.RexCast import org.partiql.plan.rex.RexCoalesce +import org.partiql.plan.rex.RexDispatch import org.partiql.plan.rex.RexError import org.partiql.plan.rex.RexLit import org.partiql.plan.rex.RexNullIf @@ -51,7 +49,7 @@ import org.partiql.plan.rex.RexVar * * Replacement for https://github.com/partiql/partiql-lang-kotlin/blob/main/partiql-planner/src/test/kotlin/org/partiql/planner/util/PlanNodeEquivalentVisitor.kt#L16 */ -object PlanEquivalenceVisitor : Visitor { +object PlanEquivalenceOperatorVisitor : OperatorVisitor { @JvmStatic public fun equals(p1: Plan, p2: Plan): Boolean = visitPlan(p1, p2) @@ -60,16 +58,16 @@ object PlanEquivalenceVisitor : Visitor { if (other !is Plan) { return false } - val op1 = plan.getOperation() - val op2 = other.getOperation() + val op1 = plan.action + val op2 = other.action return visitOperation(op1, op2) } - public fun visitOperation(operation: Operation, other: Any): Boolean { - if (other !is Operation) { + public fun visitOperation(action: Action, other: Any): Boolean { + if (other !is Action) { return false } - if (operation is Operation.Query && other is Operation.Query) { + if (action is Action.Query && other is Action.Query) { // TODO return true } @@ -155,8 +153,8 @@ object PlanEquivalenceVisitor : Visitor { return super.visitCall(rex, other) } - override fun visitCallDynamic(rex: RexCallDynamic, other: Any): Boolean { - return super.visitCallDynamic(rex, other) + override fun visitDispatch(rex: RexDispatch, other: Any): Boolean { + return super.visitDispatch(rex, other) } override fun visitCase(rex: RexCase, other: Any): Boolean { diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt index edf5f02d12..91f4b80452 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt @@ -128,7 +128,7 @@ class PlanTest { } private fun assertPlanEqual(actual: Plan, expected: Plan) { - assert(PlanEquivalenceVisitor.equals(actual, expected)) { + assert(PlanEquivalenceOperatorVisitor.equals(actual, expected)) { buildString { appendLine("plans were not equivalent") // TODO print diff diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt index b426325d6b..7dc4c9c431 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt @@ -4,7 +4,7 @@ import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.MethodSource import org.partiql.ast.Statement import org.partiql.parser.PartiQLParser -import org.partiql.plan.Operation +import org.partiql.plan.Action import org.partiql.planner.internal.typer.CompilerType import org.partiql.planner.internal.typer.PlanTyper.Companion.toCType import org.partiql.planner.util.PErrorAlwaysMissingCollector @@ -404,8 +404,8 @@ internal class PlannerPErrorReportingTests { plan, pc, tc.assertion ) - val statement = plan.getOperation() as Operation.Query - val actualType = statement.getType().getPType() + val statement = plan.action as Action.Query + val actualType = statement.rex.type.pType assertEquals(tc.expectedType, actualType) } diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt index 191ccf9216..ab8ee3284c 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt @@ -8,9 +8,9 @@ import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import org.junit.jupiter.params.provider.ArgumentsSource import org.partiql.parser.PartiQLParser +import org.partiql.plan.Action import org.partiql.plan.Exclusion -import org.partiql.plan.Operation -import org.partiql.plan.builder.PlanFactory +import org.partiql.plan.Operators import org.partiql.plan.rel.RelExclude import org.partiql.plan.rel.RelProject import org.partiql.plan.rex.RexSelect @@ -18,6 +18,7 @@ import org.partiql.plan.rex.RexVar import org.partiql.planner.PartiQLPlanner import org.partiql.spi.catalog.Catalog import org.partiql.spi.catalog.Session +import org.partiql.types.PType import java.util.stream.Stream import kotlin.test.assertEquals @@ -30,8 +31,8 @@ class SubsumptionTest { private val catalog = Catalog.builder().name("default").build() } - private fun getExcludeClause(statement: Operation): RelExclude { - val queryExpr = (statement as Operation.Query).getRex() + private fun getExcludeClause(statement: Action): RelExclude { + val queryExpr = (statement as Action.Query).getRex() val relProject = (queryExpr as RexSelect).getInput() as RelProject return (relProject.getInput()) as RelExclude } @@ -43,7 +44,7 @@ class SubsumptionTest { val statement = parseResult.statements[0] val session = Session.builder().catalog("default").catalogs(catalog).build() val plan = planner.plan(statement, session).plan - val excludeClause = getExcludeClause(plan.getOperation()).getExclusions() + val excludeClause = getExcludeClause(plan.action).getExclusions() assertEquals(tc.expectedExcludeExprs, excludeClause) } @@ -59,9 +60,9 @@ class SubsumptionTest { return parameters.map { Arguments.of(it) }.stream() } - private val factory = PlanFactory.STANDARD + private val factory = Operators.STANDARD - private fun rexOpVar(depth: Int, offset: Int): RexVar = factory.rexVar(depth, offset) + private fun rexOpVar(depth: Int, offset: Int): RexVar = factory.variable(depth, offset, PType.unknown()) private val parameters = listOf( SubsumptionTC( diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt index 42d534ebd7..4eebfbeb39 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt @@ -3,7 +3,7 @@ package org.partiql.planner.internal.typer import org.junit.jupiter.api.DynamicContainer import org.junit.jupiter.api.DynamicTest import org.partiql.parser.PartiQLParser -import org.partiql.plan.Operation +import org.partiql.plan.Action import org.partiql.planner.PartiQLPlanner import org.partiql.planner.test.PartiQLTest import org.partiql.planner.test.PartiQLTestProvider @@ -111,8 +111,8 @@ abstract class PartiQLTyperTestBase { val pc = PErrorCollector() if (key is TestResult.Success) { val result = testingPipeline(statement, testName, metadata, pc) - val query = result.plan.getOperation() as Operation.Query - val actualType = query.getType().getPType() + val query = result.plan.action as Action.Query + val actualType = query.rex.type.pType // TODO: The tests need parameter checks assert(actualType.code() == key.expectedType.code()) { buildString { @@ -142,8 +142,8 @@ abstract class PartiQLTyperTestBase { } } else { val result = testingPipeline(statement, testName, metadata, pc) - val query = result.plan.getOperation() as Operation.Query - val actualType = query.getType().getPType() + val query = result.plan.action as Action.Query + val actualType = query.rex.type.pType assert(actualType.code() == PType.DYNAMIC) { buildString { this.appendLine("expected Type is : DYNAMIC") diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt index 13d06bd03b..5cf20ac191 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt @@ -13,6 +13,7 @@ import org.junit.jupiter.params.provider.ArgumentsProvider import org.junit.jupiter.params.provider.ArgumentsSource import org.junit.jupiter.params.provider.MethodSource import org.partiql.parser.PartiQLParser +import org.partiql.plan.Action import org.partiql.planner.PartiQLPlanner import org.partiql.planner.internal.PErrors import org.partiql.planner.internal.TestCatalog @@ -2819,7 +2820,7 @@ internal class PlanTyperTestsPorted { SuccessTestCase( key = PartiQLTest.Key("basics", "nullif-06"), catalog = "pql", - expected = PType.unknown().toCType() + expected = PType.dynamic().toCType() // TODO make unknown ), SuccessTestCase( key = PartiQLTest.Key("basics", "nullif-07"), @@ -2829,7 +2830,7 @@ internal class PlanTyperTestsPorted { SuccessTestCase( key = PartiQLTest.Key("basics", "nullif-08"), catalog = "pql", - expected = PType.unknown().toCType() + expected = PType.dynamic().toCType() // TODO make unknown ), SuccessTestCase( key = PartiQLTest.Key("basics", "nullif-09"), @@ -3839,8 +3840,8 @@ internal class PlanTyperTestsPorted { val collector = PErrorCollector() val plan = infer(input, session, collector) - when (val statement = plan.getOperation()) { - is org.partiql.plan.Operation.Query -> { + when (val statement = plan.action) { + is Action.Query -> { assert(collector.problems.isEmpty()) { // Throw internal error for debugging collector.problems.firstOrNull { it.code() == PError.INTERNAL_ERROR }?.let { pError -> @@ -3852,7 +3853,7 @@ internal class PlanTyperTestsPorted { PlanPrinter.append(this, plan) } } - val actual = statement.getType().getPType() + val actual = statement.rex.type.pType assert(tc.expected == actual) { buildString { appendLine() @@ -3881,8 +3882,8 @@ internal class PlanTyperTestsPorted { val input = tc.query ?: testProvider[tc.key!!]!!.statement val plan = infer(input, session, collector) - when (val operation = plan.getOperation()) { - is org.partiql.plan.Operation.Query -> { + when (val operation = plan.action) { + is Action.Query -> { assert(collector.problems.isNotEmpty()) { buildString { appendLine("Expected to find problems, but none were found.") @@ -3891,7 +3892,7 @@ internal class PlanTyperTestsPorted { } } if (tc.expected != null) { - val actual = operation.getType().getPType() + val actual = operation.rex.type.pType assert(tc.expected == actual) { buildString { appendLine() diff --git a/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt b/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt index f17b322a69..b28415ec0c 100644 --- a/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt +++ b/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt @@ -11,7 +11,7 @@ import org.partiql.eval.Mode import org.partiql.eval.Statement import org.partiql.eval.compiler.PartiQLCompiler import org.partiql.parser.PartiQLParser -import org.partiql.plan.Operation.Query +import org.partiql.plan.Action.Query import org.partiql.planner.PartiQLPlanner import org.partiql.runner.CompileType import org.partiql.runner.ION @@ -193,7 +193,7 @@ class EvalExecutor( assertEquals(1, parseResult.statements.size) val stmt = parseResult.statements[0] val plan = planner.plan(stmt, session).plan - return (plan.getOperation() as Query).getRex().getType().getPType() + return (plan.action as Query).getRex().getType().getPType() } /**