From a54f6ad5a2304a008184d6127e38d27141f31914 Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Wed, 28 Aug 2024 11:14:22 -0700 Subject: [PATCH] Adds paths to V1 plans (#1571) --- partiql-plan/api/partiql-plan.api | 63 +++++++++---------- .../partiql/plan/v1/builder/PlanFactory.kt | 43 +++++++++++-- .../org/partiql/plan/v1/builder/RexBuilder.kt | 5 +- .../partiql/plan/v1/operator/rex/RexPath.kt | 41 ------------ .../plan/v1/operator/rex/RexPathIndex.kt | 35 +++++++++++ .../plan/v1/operator/rex/RexPathKey.kt | 35 +++++++++++ .../plan/v1/operator/rex/RexPathSymbol.kt | 35 +++++++++++ .../plan/v1/operator/rex/RexSubquery.kt | 14 ++++- .../partiql/plan/v1/operator/rex/RexTable.kt | 24 +++---- .../plan/v1/operator/rex/RexVisitor.kt | 8 +-- 10 files changed, 200 insertions(+), 103 deletions(-) delete mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPath.kt create mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathIndex.kt create mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathKey.kt create mode 100644 partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathSymbol.kt diff --git a/partiql-plan/api/partiql-plan.api b/partiql-plan/api/partiql-plan.api index 807de9293a..907474e6e4 100644 --- a/partiql-plan/api/partiql-plan.api +++ b/partiql-plan/api/partiql-plan.api @@ -2549,17 +2549,20 @@ public abstract interface class org/partiql/plan/v1/builder/PlanFactory { public abstract fun rexError (Ljava/lang/String;Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexError; public abstract fun rexLit (Lorg/partiql/eval/value/Datum;)Lorg/partiql/plan/v1/operator/rex/RexLit; public abstract fun rexMissing (Ljava/lang/String;Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexMissing; + public abstract fun rexPathIndex (Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexPathIndex; + public abstract fun rexPathKey (Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexPathKey; + public abstract fun rexPathSymbol (Lorg/partiql/plan/v1/operator/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/v1/operator/rex/RexPathSymbol; public abstract fun rexPivot (Lorg/partiql/plan/v1/operator/rel/Rel;Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexPivot; public abstract fun rexSelect (Lorg/partiql/plan/v1/operator/rel/Rel;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexSelect; public abstract fun rexSpread (Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexSpread; public abstract fun rexStruct (Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexStruct; - public abstract fun rexSubquery (Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubquery; + public abstract fun rexSubquery (Lorg/partiql/plan/v1/operator/rel/Rel;Lorg/partiql/plan/v1/operator/rex/Rex;Z)Lorg/partiql/plan/v1/operator/rex/RexSubquery; public abstract fun rexSubqueryComp (Ljava/util/List;Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp; public abstract fun rexSubqueryComp (Ljava/util/List;Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp$Quantifier;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp; public abstract fun rexSubqueryIn (Ljava/util/List;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryIn; public abstract fun rexSubqueryIn (Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryIn; public abstract fun rexSubqueryTest (Lorg/partiql/plan/v1/operator/rex/RexSubqueryTest$Test;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryTest; - public abstract fun rexTable (Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/plan/v1/operator/rex/RexTable; + public abstract fun rexTable (Lorg/partiql/planner/catalog/Table;)Lorg/partiql/plan/v1/operator/rex/RexTable; } public final class org/partiql/plan/v1/builder/PlanFactory$Companion { @@ -2599,17 +2602,20 @@ public final class org/partiql/plan/v1/builder/PlanFactory$DefaultImpls { public static fun rexError (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/lang/String;Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexError; public static fun rexLit (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/eval/value/Datum;)Lorg/partiql/plan/v1/operator/rex/RexLit; public static fun rexMissing (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/lang/String;Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexMissing; + public static fun rexPathIndex (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexPathIndex; + public static fun rexPathKey (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexPathKey; + public static fun rexPathSymbol (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rex/Rex;Ljava/lang/String;)Lorg/partiql/plan/v1/operator/rex/RexPathSymbol; public static fun rexPivot (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rel/Rel;Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexPivot; public static fun rexSelect (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rel/Rel;Lorg/partiql/plan/v1/operator/rex/Rex;)Lorg/partiql/plan/v1/operator/rex/RexSelect; public static fun rexSpread (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexSpread; public static fun rexStruct (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/util/List;)Lorg/partiql/plan/v1/operator/rex/RexStruct; - public static fun rexSubquery (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubquery; + public static fun rexSubquery (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rel/Rel;Lorg/partiql/plan/v1/operator/rex/Rex;Z)Lorg/partiql/plan/v1/operator/rex/RexSubquery; public static fun rexSubqueryComp (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp; public static fun rexSubqueryComp (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp$Comp;Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp$Quantifier;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryComp; public static fun rexSubqueryIn (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/util/List;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryIn; public static fun rexSubqueryIn (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rex/Rex;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryIn; public static fun rexSubqueryTest (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/plan/v1/operator/rex/RexSubqueryTest$Test;Lorg/partiql/plan/v1/operator/rel/Rel;)Lorg/partiql/plan/v1/operator/rex/RexSubqueryTest; - public static fun rexTable (Lorg/partiql/plan/v1/builder/PlanFactory;Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/plan/v1/operator/rex/RexTable; + public static fun rexTable (Lorg/partiql/plan/v1/builder/PlanFactory;Lorg/partiql/planner/catalog/Table;)Lorg/partiql/plan/v1/operator/rex/RexTable; } public final class org/partiql/plan/v1/builder/RelBuilder { @@ -3188,40 +3194,34 @@ public final class org/partiql/plan/v1/operator/rex/RexMissing$DefaultImpls { public static fun getType (Lorg/partiql/plan/v1/operator/rex/RexMissing;)Lorg/partiql/types/PType; } -public abstract interface class org/partiql/plan/v1/operator/rex/RexPath : org/partiql/plan/v1/operator/rex/Rex { - public abstract fun accept (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getRoot ()Lorg/partiql/plan/v1/operator/rex/Rex; -} - -public final class org/partiql/plan/v1/operator/rex/RexPath$DefaultImpls { - public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPath;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; -} - -public abstract interface class org/partiql/plan/v1/operator/rex/RexPath$Index : org/partiql/plan/v1/operator/rex/RexPath { +public abstract interface class org/partiql/plan/v1/operator/rex/RexPathIndex : org/partiql/plan/v1/operator/rex/Rex { public abstract fun accept (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun getIndex ()Lorg/partiql/plan/v1/operator/rex/Rex; + public abstract fun getOperand ()Lorg/partiql/plan/v1/operator/rex/Rex; } -public final class org/partiql/plan/v1/operator/rex/RexPath$Index$DefaultImpls { - public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPath$Index;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; +public final class org/partiql/plan/v1/operator/rex/RexPathIndex$DefaultImpls { + public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPathIndex;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; } -public abstract interface class org/partiql/plan/v1/operator/rex/RexPath$Key : org/partiql/plan/v1/operator/rex/RexPath { +public abstract interface class org/partiql/plan/v1/operator/rex/RexPathKey : org/partiql/plan/v1/operator/rex/Rex { public abstract fun accept (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun getKey ()Lorg/partiql/plan/v1/operator/rex/Rex; + public abstract fun getOperand ()Lorg/partiql/plan/v1/operator/rex/Rex; } -public final class org/partiql/plan/v1/operator/rex/RexPath$Key$DefaultImpls { - public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPath$Key;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; +public final class org/partiql/plan/v1/operator/rex/RexPathKey$DefaultImpls { + public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPathKey;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; } -public abstract interface class org/partiql/plan/v1/operator/rex/RexPath$Symbol : org/partiql/plan/v1/operator/rex/RexPath { +public abstract interface class org/partiql/plan/v1/operator/rex/RexPathSymbol : org/partiql/plan/v1/operator/rex/Rex { public abstract fun accept (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun getOperand ()Lorg/partiql/plan/v1/operator/rex/Rex; public abstract fun getSymbol ()Ljava/lang/String; } -public final class org/partiql/plan/v1/operator/rex/RexPath$Symbol$DefaultImpls { - public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPath$Symbol;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; +public final class org/partiql/plan/v1/operator/rex/RexPathSymbol$DefaultImpls { + public static fun accept (Lorg/partiql/plan/v1/operator/rex/RexPathSymbol;Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; } public abstract interface class org/partiql/plan/v1/operator/rex/RexPivot : org/partiql/plan/v1/operator/rex/Rex { @@ -3286,6 +3286,8 @@ public abstract interface class org/partiql/plan/v1/operator/rex/RexStruct$Field public abstract interface class org/partiql/plan/v1/operator/rex/RexSubquery : org/partiql/plan/v1/operator/rex/Rex { public abstract fun accept (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun asScalar ()Z + public abstract fun getConstructor ()Lorg/partiql/plan/v1/operator/rex/Rex; public abstract fun getRel ()Lorg/partiql/plan/v1/operator/rel/Rel; } @@ -3356,9 +3358,8 @@ public final class org/partiql/plan/v1/operator/rex/RexSubqueryTest$Test : java/ public abstract interface class org/partiql/plan/v1/operator/rex/RexTable : org/partiql/plan/v1/operator/rex/Rex { public abstract fun accept (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun getCatalog ()Ljava/lang/String; public abstract fun getChildren ()Ljava/util/Collection; - public abstract fun getName ()Ljava/lang/String; + public abstract fun getTable ()Lorg/partiql/planner/catalog/Table; } public final class org/partiql/plan/v1/operator/rex/RexTable$DefaultImpls { @@ -3391,10 +3392,9 @@ public abstract interface class org/partiql/plan/v1/operator/rex/RexVisitor { public abstract fun visitError (Lorg/partiql/plan/v1/operator/rex/RexError;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitLit (Lorg/partiql/plan/v1/operator/rex/RexLit;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitMissing (Lorg/partiql/plan/v1/operator/rex/RexMissing;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPath (Lorg/partiql/plan/v1/operator/rex/RexPath;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPathIndex (Lorg/partiql/plan/v1/operator/rex/RexPath$Index;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPathKey (Lorg/partiql/plan/v1/operator/rex/RexPath$Key;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitPathSymbol (Lorg/partiql/plan/v1/operator/rex/RexPath$Symbol;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitPathIndex (Lorg/partiql/plan/v1/operator/rex/RexPathIndex;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitPathKey (Lorg/partiql/plan/v1/operator/rex/RexPathKey;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitPathSymbol (Lorg/partiql/plan/v1/operator/rex/RexPathSymbol;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitPivot (Lorg/partiql/plan/v1/operator/rex/RexPivot;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelect (Lorg/partiql/plan/v1/operator/rex/RexSelect;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSpread (Lorg/partiql/plan/v1/operator/rex/RexSpread;Ljava/lang/Object;)Ljava/lang/Object; @@ -3419,10 +3419,9 @@ public final class org/partiql/plan/v1/operator/rex/RexVisitor$DefaultImpls { public static fun visitError (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexError;Ljava/lang/Object;)Ljava/lang/Object; public static fun visitLit (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexLit;Ljava/lang/Object;)Ljava/lang/Object; public static fun visitMissing (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexMissing;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPath (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPath;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPathIndex (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPath$Index;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPathKey (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPath$Key;Ljava/lang/Object;)Ljava/lang/Object; - public static fun visitPathSymbol (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPath$Symbol;Ljava/lang/Object;)Ljava/lang/Object; + public static fun visitPathIndex (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPathIndex;Ljava/lang/Object;)Ljava/lang/Object; + public static fun visitPathKey (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPathKey;Ljava/lang/Object;)Ljava/lang/Object; + public static fun visitPathSymbol (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPathSymbol;Ljava/lang/Object;)Ljava/lang/Object; public static fun visitPivot (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexPivot;Ljava/lang/Object;)Ljava/lang/Object; public static fun visitSelect (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexSelect;Ljava/lang/Object;)Ljava/lang/Object; public static fun visitSpread (Lorg/partiql/plan/v1/operator/rex/RexVisitor;Lorg/partiql/plan/v1/operator/rex/RexSpread;Ljava/lang/Object;)Ljava/lang/Object; diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/PlanFactory.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/PlanFactory.kt index 8bc01f219f..8d4439ed85 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/PlanFactory.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/PlanFactory.kt @@ -57,6 +57,12 @@ import org.partiql.plan.v1.operator.rex.RexLit import org.partiql.plan.v1.operator.rex.RexLitImpl import org.partiql.plan.v1.operator.rex.RexMissing import org.partiql.plan.v1.operator.rex.RexMissingImpl +import org.partiql.plan.v1.operator.rex.RexPathIndex +import org.partiql.plan.v1.operator.rex.RexPathIndexImpl +import org.partiql.plan.v1.operator.rex.RexPathKey +import org.partiql.plan.v1.operator.rex.RexPathKeyImpl +import org.partiql.plan.v1.operator.rex.RexPathSymbol +import org.partiql.plan.v1.operator.rex.RexPathSymbolImpl import org.partiql.plan.v1.operator.rex.RexPivot import org.partiql.plan.v1.operator.rex.RexPivotImpl import org.partiql.plan.v1.operator.rex.RexSelect @@ -77,6 +83,7 @@ import org.partiql.plan.v1.operator.rex.RexTable import org.partiql.plan.v1.operator.rex.RexTableImpl import org.partiql.plan.v1.operator.rex.RexVar import org.partiql.plan.v1.operator.rex.RexVarImpl +import org.partiql.planner.catalog.Table import org.partiql.spi.fn.Fn import org.partiql.types.PType @@ -397,7 +404,32 @@ public interface PlanFactory { */ public fun rexLit(value: Datum): RexLit = RexLitImpl(value) - // TODO PATHS + /** + * Create a [RexPathIndex] instance. + * + * @param operand + * @param index + * @return + */ + public fun rexPathIndex(operand: Rex, index: Rex): RexPathIndex = RexPathIndexImpl(operand, index) + + /** + * Create a [RexPathKey] instance. + * + * @param operand + * @param key + * @return + */ + public fun rexPathKey(operand: Rex, key: Rex): RexPathKey = RexPathKeyImpl(operand, key) + + /** + * Create a [RexPathSymbol] instance. + * + * @param operand + * @param symbol + * @return + */ + public fun rexPathSymbol(operand: Rex, symbol: String): RexPathSymbol = RexPathSymbolImpl(operand, symbol) /** * Create a [RexPivot] instance. @@ -437,10 +469,12 @@ public interface PlanFactory { /** * 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): RexSubquery = RexSubqueryImpl(rel) + public fun rexSubquery(rel: Rel, constructor: Rex, asScalar: Boolean): RexSubquery = RexSubqueryImpl(rel, constructor, asScalar) /** * Create a [RexSubqueryComp] instance. @@ -499,9 +533,8 @@ public interface PlanFactory { /** * Create a [RexTable] instance. * - * @param catalog - * @param name + * @param table * @return */ - public fun rexTable(catalog: String, name: String): RexTable = RexTableImpl(catalog, name) + public fun rexTable(table: Table): RexTable = RexTableImpl(table) } diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/RexBuilder.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/RexBuilder.kt index 7194f19ebf..f70e825456 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/RexBuilder.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/builder/RexBuilder.kt @@ -86,8 +86,9 @@ public class RexBuilder private constructor(rex: Builder) { */ @JvmStatic public fun subquery(rel: RelBuilder): RexBuilder = RexBuilder { - val _rel = rel.build(it) - it.rexSubquery(_rel) + error("subquery builders are removed until they are fixed in partiql-planner") + // val _rel = rel.build(it) + // it.rexSubquery(_rel) } /** diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPath.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPath.kt deleted file mode 100644 index 34dc179ae2..0000000000 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPath.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.partiql.plan.v1.operator.rex - -/** - * TODO DOCUMENTATION - */ -public interface RexPath : Rex { - - public fun getRoot(): Rex - - override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPath(this, ctx) - - /** - * TODO DOCUMENTATION - */ - public interface Index : RexPath { - - public fun getIndex(): Rex - - override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPathIndex(this, ctx) - } - - /** - * TODO DOCUMENTATION - */ - public interface Key : RexPath { - - public fun getKey(): Rex - - override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPathKey(this, ctx) - } - - /** - * TODO DOCUMENTATION - */ - public interface Symbol : RexPath { - - public fun getSymbol(): String - - override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPathSymbol(this, ctx) - } -} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathIndex.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathIndex.kt new file mode 100644 index 0000000000..5da907b39b --- /dev/null +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathIndex.kt @@ -0,0 +1,35 @@ +package org.partiql.plan.v1.operator.rex + +import org.partiql.types.PType + +/** + * Logical path index operator. + */ +public interface RexPathIndex : Rex { + + public fun getOperand(): Rex + + public fun getIndex(): Rex + + override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPathIndex(this, ctx) +} + +/** + * Standard internal implementation for [RexPathIndex]. + */ +internal class RexPathIndexImpl(operand: Rex, index: Rex) : RexPathIndex { + + // DO NOT USE FINAL + private var _operand = operand + private var _index = index + + override fun getOperand() = _operand + + override fun getIndex() = _index + + override fun getType(): PType { + TODO("Not yet implemented") + } + + override fun getChildren(): Collection = listOf(_operand, _index) +} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathKey.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathKey.kt new file mode 100644 index 0000000000..6496944671 --- /dev/null +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathKey.kt @@ -0,0 +1,35 @@ +package org.partiql.plan.v1.operator.rex + +import org.partiql.types.PType + +/** + * Logical operator for path lookup by key. + */ +public interface RexPathKey : Rex { + + public fun getOperand(): Rex + + public fun getKey(): Rex + + override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPathKey(this, ctx) +} + +/** + * Standard internal implementation for [RexPathKey]. + */ +internal class RexPathKeyImpl(operand: Rex, key: Rex) : RexPathKey { + + // DO NOT USE FINAL + private var _operand = operand + private var _key = key + + override fun getOperand() = _operand + + override fun getKey() = _key + + override fun getType(): PType { + TODO("Not yet implemented") + } + + override fun getChildren(): Collection = listOf(_operand, _key) +} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathSymbol.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathSymbol.kt new file mode 100644 index 0000000000..d4daeafbb3 --- /dev/null +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexPathSymbol.kt @@ -0,0 +1,35 @@ +package org.partiql.plan.v1.operator.rex + +import org.partiql.types.PType + +/** + * Logical operator for path lookup by symbol. + */ +public interface RexPathSymbol : Rex { + + public fun getOperand(): Rex + + public fun getSymbol(): String + + override fun accept(visitor: RexVisitor, ctx: C): R = visitor.visitPathSymbol(this, ctx) +} + +/** + * Standard internal implementation for [RexPathSymbol]. + */ +internal class RexPathSymbolImpl(operand: Rex, symbol: String) : RexPathSymbol { + + // DO NOT USE FINAL + private var _operand = operand + private var _symbol = symbol + + override fun getOperand() = _operand + + override fun getSymbol() = _symbol + + override fun getType(): PType { + TODO("Not yet implemented") + } + + override fun getChildren(): Collection = listOf(_operand) +} diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexSubquery.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexSubquery.kt index 48600a4d03..307609b03f 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexSubquery.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexSubquery.kt @@ -10,19 +10,31 @@ public interface RexSubquery : Rex { public fun getRel(): 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: RexVisitor, ctx: C): R = visitor.visitSubquery(this, ctx) } /** * Implementation of scalar subquery coercion. */ -internal class RexSubqueryImpl(rel: Rel) : RexSubquery { +internal class RexSubqueryImpl(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(): Rel = _rel + override fun getConstructor(): Rex = _constructor + + override fun asScalar(): Boolean = _asScalar + override fun getType(): PType { TODO("Not yet implemented") } diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexTable.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexTable.kt index 6f0d7ebb00..494641a47a 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexTable.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexTable.kt @@ -1,19 +1,14 @@ package org.partiql.plan.v1.operator.rex +import org.partiql.planner.catalog.Table import org.partiql.types.PType /** * Global variable references e.g. tables and views. - * TODO NAMING?? RexTable?? */ public interface RexTable : Rex { - public fun getCatalog(): String - - /** - * TODO replace with Catalog Name - */ - public fun getName(): String + public fun getTable(): Table override fun getChildren(): Collection = emptyList() @@ -23,15 +18,12 @@ public interface RexTable : Rex { /** * Default [RexTable] implementation. */ -internal class RexTableImpl(catalog: String, name: String) : RexTable { +internal class RexTableImpl(table: Table) : RexTable { // DO NOT USE FINAL - private var _catalog = catalog - private var _name = name - - override fun getCatalog(): String = _catalog + private var _table = table - override fun getName(): String = _name + override fun getTable(): Table = _table override fun getType(): PType { TODO("Not yet implemented") @@ -40,15 +32,13 @@ internal class RexTableImpl(catalog: String, name: String) : RexTable { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is RexTable) return false - if (_catalog != other.getCatalog()) return false - if (_name != other.getName()) return false + if (_table != other.getTable()) return false return true } override fun hashCode(): Int { var result = 1 - result = 31 * result + _catalog.hashCode() - result = 31 * result + _name.hashCode() + result = 31 * result + _table.hashCode() return result } } diff --git a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexVisitor.kt b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexVisitor.kt index ad1654fee5..ac96adc10d 100644 --- a/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexVisitor.kt +++ b/partiql-plan/src/main/kotlin/org/partiql/plan/v1/operator/rex/RexVisitor.kt @@ -37,13 +37,11 @@ public interface RexVisitor { public fun visitMissing(rex: RexMissing, ctx: C): R = defaultVisit(rex, ctx) - public fun visitPath(rex: RexPath, ctx: C): R = rex.accept(this, ctx) + public fun visitPathIndex(rex: RexPathIndex, ctx: C): R = defaultVisit(rex, ctx) - public fun visitPathIndex(rex: RexPath.Index, ctx: C): R = defaultVisit(rex, ctx) + public fun visitPathKey(rex: RexPathKey, ctx: C): R = defaultVisit(rex, ctx) - public fun visitPathKey(rex: RexPath.Key, ctx: C): R = defaultVisit(rex, ctx) - - public fun visitPathSymbol(rex: RexPath.Symbol, 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)