diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index 4e35fd47c2..2a0e36a4ef 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -6,7 +6,6 @@ public final class org/partiql/ast/Ast { public static final fun excludeStepStructField (Lorg/partiql/ast/Identifier$Symbol;)Lorg/partiql/ast/Exclude$Step$StructField; public static final fun excludeStepStructWildcard ()Lorg/partiql/ast/Exclude$Step$StructWildcard; public static final fun exprAnd (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$And; - public static final fun exprBagOp (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)Lorg/partiql/ast/Expr$BagOp; public static final fun exprBetween (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)Lorg/partiql/ast/Expr$Between; public static final fun exprCall (Lorg/partiql/ast/Identifier;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/Expr$Call; public static final fun exprCanCast (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Type;)Lorg/partiql/ast/Expr$CanCast; @@ -37,8 +36,7 @@ public final class org/partiql/ast/Ast { public static final fun exprPathStepUnpivot ()Lorg/partiql/ast/Expr$Path$Step$Unpivot; public static final fun exprPathStepWildcard ()Lorg/partiql/ast/Expr$Path$Step$Wildcard; public static final fun exprPosition (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Position; - public static final fun exprSFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$SFW; - public static final fun exprSFWSetOp (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;)Lorg/partiql/ast/Expr$SFW$SetOp; + public static final fun exprQuerySet (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$QuerySet; public static final fun exprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)Lorg/partiql/ast/Expr$SessionAttribute; public static final fun exprStruct (Ljava/util/List;)Lorg/partiql/ast/Expr$Struct; public static final fun exprStructField (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Struct$Field; @@ -84,6 +82,8 @@ public final class org/partiql/ast/Ast { public static final fun path (Lorg/partiql/ast/Identifier$Symbol;Ljava/util/List;)Lorg/partiql/ast/Path; public static final fun pathStepIndex (I)Lorg/partiql/ast/Path$Step$Index; public static final fun pathStepSymbol (Lorg/partiql/ast/Identifier$Symbol;)Lorg/partiql/ast/Path$Step$Symbol; + public static final fun queryBodySFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/QueryBody$SFW; + public static final fun queryBodySetOp (Lorg/partiql/ast/SetOp;ZLorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/QueryBody$SetOp; public static final fun returning (Ljava/util/List;)Lorg/partiql/ast/Returning; public static final fun returningColumn (Lorg/partiql/ast/Returning$Column$Status;Lorg/partiql/ast/Returning$Column$Age;Lorg/partiql/ast/Returning$Column$Value;)Lorg/partiql/ast/Returning$Column; public static final fun returningColumnValueExpression (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Returning$Column$Value$Expression; @@ -333,31 +333,6 @@ public final class org/partiql/ast/Expr$And$Companion { public final fun builder ()Lorg/partiql/ast/builder/ExprAndBuilder; } -public final class org/partiql/ast/Expr$BagOp : org/partiql/ast/Expr { - public static final field Companion Lorg/partiql/ast/Expr$BagOp$Companion; - public final field lhs Lorg/partiql/ast/Expr; - public final field outer Ljava/lang/Boolean; - public final field rhs Lorg/partiql/ast/Expr; - public final field type Lorg/partiql/ast/SetOp; - public fun (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)V - public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public static final fun builder ()Lorg/partiql/ast/builder/ExprBagOpBuilder; - public final fun component1 ()Lorg/partiql/ast/SetOp; - public final fun component2 ()Lorg/partiql/ast/Expr; - public final fun component3 ()Lorg/partiql/ast/Expr; - public final fun component4 ()Ljava/lang/Boolean; - public final fun copy (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)Lorg/partiql/ast/Expr$BagOp; - public static synthetic fun copy$default (Lorg/partiql/ast/Expr$BagOp;Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;ILjava/lang/Object;)Lorg/partiql/ast/Expr$BagOp; - public fun equals (Ljava/lang/Object;)Z - public fun getChildren ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/partiql/ast/Expr$BagOp$Companion { - public final fun builder ()Lorg/partiql/ast/builder/ExprBagOpBuilder; -} - public final class org/partiql/ast/Expr$Between : org/partiql/ast/Expr { public static final field Companion Lorg/partiql/ast/Expr$Between$Companion; public final field from Lorg/partiql/ast/Expr; @@ -1014,64 +989,29 @@ public final class org/partiql/ast/Expr$Position$Companion { public final fun builder ()Lorg/partiql/ast/builder/ExprPositionBuilder; } -public final class org/partiql/ast/Expr$SFW : org/partiql/ast/Expr { - public static final field Companion Lorg/partiql/ast/Expr$SFW$Companion; - public final field exclude Lorg/partiql/ast/Exclude; - public final field from Lorg/partiql/ast/From; - public final field groupBy Lorg/partiql/ast/GroupBy; - public final field having Lorg/partiql/ast/Expr; - public final field let Lorg/partiql/ast/Let; +public final class org/partiql/ast/Expr$QuerySet : org/partiql/ast/Expr { + public static final field Companion Lorg/partiql/ast/Expr$QuerySet$Companion; + public final field body Lorg/partiql/ast/QueryBody; public final field limit Lorg/partiql/ast/Expr; public final field offset Lorg/partiql/ast/Expr; public final field orderBy Lorg/partiql/ast/OrderBy; - public final field select Lorg/partiql/ast/Select; - public final field setOp Lorg/partiql/ast/Expr$SFW$SetOp; - public final field where Lorg/partiql/ast/Expr; - public fun (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public fun (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public static final fun builder ()Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun component1 ()Lorg/partiql/ast/Select; - public final fun component10 ()Lorg/partiql/ast/Expr; - public final fun component11 ()Lorg/partiql/ast/Expr; - public final fun component2 ()Lorg/partiql/ast/Exclude; - public final fun component3 ()Lorg/partiql/ast/From; - public final fun component4 ()Lorg/partiql/ast/Let; - public final fun component5 ()Lorg/partiql/ast/Expr; - public final fun component6 ()Lorg/partiql/ast/GroupBy; - public final fun component7 ()Lorg/partiql/ast/Expr; - public final fun component8 ()Lorg/partiql/ast/Expr$SFW$SetOp; - public final fun component9 ()Lorg/partiql/ast/OrderBy; - public final fun copy (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$SFW; - public static synthetic fun copy$default (Lorg/partiql/ast/Expr$SFW;Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$SFW; - public fun equals (Ljava/lang/Object;)Z - public fun getChildren ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/partiql/ast/Expr$SFW$Companion { - public final fun builder ()Lorg/partiql/ast/builder/ExprSfwBuilder; -} - -public final class org/partiql/ast/Expr$SFW$SetOp : org/partiql/ast/AstNode { - public static final field Companion Lorg/partiql/ast/Expr$SFW$SetOp$Companion; - public final field operand Lorg/partiql/ast/Expr$SFW; - public final field type Lorg/partiql/ast/SetOp; - public fun (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;)V - public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public static final fun builder ()Lorg/partiql/ast/builder/ExprSfwSetOpBuilder; - public final fun component1 ()Lorg/partiql/ast/SetOp; - public final fun component2 ()Lorg/partiql/ast/Expr$SFW; - public final fun copy (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;)Lorg/partiql/ast/Expr$SFW$SetOp; - public static synthetic fun copy$default (Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;ILjava/lang/Object;)Lorg/partiql/ast/Expr$SFW$SetOp; + public static final fun builder ()Lorg/partiql/ast/builder/ExprQuerySetBuilder; + public final fun component1 ()Lorg/partiql/ast/QueryBody; + public final fun component2 ()Lorg/partiql/ast/OrderBy; + public final fun component3 ()Lorg/partiql/ast/Expr; + public final fun component4 ()Lorg/partiql/ast/Expr; + public final fun copy (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$QuerySet; + public static synthetic fun copy$default (Lorg/partiql/ast/Expr$QuerySet;Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$QuerySet; public fun equals (Ljava/lang/Object;)Z public fun getChildren ()Ljava/util/List; public fun hashCode ()I public fun toString ()Ljava/lang/String; } -public final class org/partiql/ast/Expr$SFW$SetOp$Companion { - public final fun builder ()Lorg/partiql/ast/builder/ExprSfwSetOpBuilder; +public final class org/partiql/ast/Expr$QuerySet$Companion { + public final fun builder ()Lorg/partiql/ast/builder/ExprQuerySetBuilder; } public final class org/partiql/ast/Expr$SessionAttribute : org/partiql/ast/Expr { @@ -2135,6 +2075,66 @@ public final class org/partiql/ast/Path$Step$Symbol$Companion { public final fun builder ()Lorg/partiql/ast/builder/PathStepSymbolBuilder; } +public abstract class org/partiql/ast/QueryBody : org/partiql/ast/AstNode { + public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class org/partiql/ast/QueryBody$SFW : org/partiql/ast/QueryBody { + public static final field Companion Lorg/partiql/ast/QueryBody$SFW$Companion; + public final field exclude Lorg/partiql/ast/Exclude; + public final field from Lorg/partiql/ast/From; + public final field groupBy Lorg/partiql/ast/GroupBy; + public final field having Lorg/partiql/ast/Expr; + public final field let Lorg/partiql/ast/Let; + public final field select Lorg/partiql/ast/Select; + public final field where Lorg/partiql/ast/Expr; + public fun (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;)V + public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun builder ()Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun component1 ()Lorg/partiql/ast/Select; + public final fun component2 ()Lorg/partiql/ast/Exclude; + public final fun component3 ()Lorg/partiql/ast/From; + public final fun component4 ()Lorg/partiql/ast/Let; + public final fun component5 ()Lorg/partiql/ast/Expr; + public final fun component6 ()Lorg/partiql/ast/GroupBy; + public final fun component7 ()Lorg/partiql/ast/Expr; + public final fun copy (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/QueryBody$SFW; + public static synthetic fun copy$default (Lorg/partiql/ast/QueryBody$SFW;Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/QueryBody$SFW; + public fun equals (Ljava/lang/Object;)Z + public fun getChildren ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/partiql/ast/QueryBody$SFW$Companion { + public final fun builder ()Lorg/partiql/ast/builder/QueryBodySfwBuilder; +} + +public final class org/partiql/ast/QueryBody$SetOp : org/partiql/ast/QueryBody { + public static final field Companion Lorg/partiql/ast/QueryBody$SetOp$Companion; + public final field isOuter Z + public final field lhs Lorg/partiql/ast/Expr; + public final field rhs Lorg/partiql/ast/Expr; + public final field type Lorg/partiql/ast/SetOp; + public fun (Lorg/partiql/ast/SetOp;ZLorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun builder ()Lorg/partiql/ast/builder/QueryBodySetOpBuilder; + public final fun component1 ()Lorg/partiql/ast/SetOp; + public final fun component2 ()Z + public final fun component3 ()Lorg/partiql/ast/Expr; + public final fun component4 ()Lorg/partiql/ast/Expr; + public final fun copy (Lorg/partiql/ast/SetOp;ZLorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/QueryBody$SetOp; + public static synthetic fun copy$default (Lorg/partiql/ast/QueryBody$SetOp;Lorg/partiql/ast/SetOp;ZLorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/QueryBody$SetOp; + public fun equals (Ljava/lang/Object;)Z + public fun getChildren ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/partiql/ast/QueryBody$SetOp$Companion { + public final fun builder ()Lorg/partiql/ast/builder/QueryBodySetOpBuilder; +} + public final class org/partiql/ast/Returning : org/partiql/ast/AstNode { public static final field Companion Lorg/partiql/ast/Returning$Companion; public final field columns Ljava/util/List; @@ -3860,8 +3860,6 @@ public final class org/partiql/ast/builder/AstBuilder { public static synthetic fun excludeStepStructWildcard$default (Lorg/partiql/ast/builder/AstBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Exclude$Step$StructWildcard; public final fun exprAnd (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$And; public static synthetic fun exprAnd$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$And; - public final fun exprBagOp (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$BagOp; - public static synthetic fun exprBagOp$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$BagOp; public final fun exprBetween (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Between; public static synthetic fun exprBetween$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Between; public final fun exprCall (Lorg/partiql/ast/Identifier;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Call; @@ -3922,10 +3920,8 @@ public final class org/partiql/ast/builder/AstBuilder { public static synthetic fun exprPathStepWildcard$default (Lorg/partiql/ast/builder/AstBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Path$Step$Wildcard; public final fun exprPosition (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Position; public static synthetic fun exprPosition$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Position; - public final fun exprSFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$SFW; - public static synthetic fun exprSFW$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$SFW; - public final fun exprSFWSetOp (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$SFW$SetOp; - public static synthetic fun exprSFWSetOp$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$SFW$SetOp; + public final fun exprQuerySet (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$QuerySet; + public static synthetic fun exprQuerySet$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$QuerySet; public final fun exprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$SessionAttribute; public static synthetic fun exprSessionAttribute$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr$SessionAttribute$Attribute;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$SessionAttribute; public final fun exprStruct (Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Struct; @@ -4016,6 +4012,10 @@ public final class org/partiql/ast/builder/AstBuilder { public static synthetic fun pathStepIndex$default (Lorg/partiql/ast/builder/AstBuilder;Ljava/lang/Integer;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Path$Step$Index; public final fun pathStepSymbol (Lorg/partiql/ast/Identifier$Symbol;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Path$Step$Symbol; public static synthetic fun pathStepSymbol$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Identifier$Symbol;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Path$Step$Symbol; + public final fun queryBodySFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/QueryBody$SFW; + public static synthetic fun queryBodySFW$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/QueryBody$SFW; + public final fun queryBodySetOp (Lorg/partiql/ast/SetOp;Ljava/lang/Boolean;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/QueryBody$SetOp; + public static synthetic fun queryBodySetOp$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/SetOp;Ljava/lang/Boolean;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/QueryBody$SetOp; public final fun returning (Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Returning; public static synthetic fun returning$default (Lorg/partiql/ast/builder/AstBuilder;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Returning; public final fun returningColumn (Lorg/partiql/ast/Returning$Column$Status;Lorg/partiql/ast/Returning$Column$Age;Lorg/partiql/ast/Returning$Column$Value;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Returning$Column; @@ -4244,25 +4244,6 @@ public final class org/partiql/ast/builder/ExprAndBuilder { public final fun setRhs (Lorg/partiql/ast/Expr;)V } -public final class org/partiql/ast/builder/ExprBagOpBuilder { - public fun ()V - public fun (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)V - public synthetic fun (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/ast/Expr$BagOp; - public final fun getLhs ()Lorg/partiql/ast/Expr; - public final fun getOuter ()Ljava/lang/Boolean; - public final fun getRhs ()Lorg/partiql/ast/Expr; - public final fun getType ()Lorg/partiql/ast/SetOp; - public final fun lhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprBagOpBuilder; - public final fun outer (Ljava/lang/Boolean;)Lorg/partiql/ast/builder/ExprBagOpBuilder; - public final fun rhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprBagOpBuilder; - public final fun setLhs (Lorg/partiql/ast/Expr;)V - public final fun setOuter (Ljava/lang/Boolean;)V - public final fun setRhs (Lorg/partiql/ast/Expr;)V - public final fun setType (Lorg/partiql/ast/SetOp;)V - public final fun type (Lorg/partiql/ast/SetOp;)Lorg/partiql/ast/builder/ExprBagOpBuilder; -} - public final class org/partiql/ast/builder/ExprBetweenBuilder { public fun ()V public fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)V @@ -4655,67 +4636,33 @@ public final class org/partiql/ast/builder/ExprPositionBuilder { public final fun setRhs (Lorg/partiql/ast/Expr;)V } -public final class org/partiql/ast/builder/ExprSessionAttributeBuilder { +public final class org/partiql/ast/builder/ExprQuerySetBuilder { public fun ()V - public fun (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)V - public synthetic fun (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun attribute (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)Lorg/partiql/ast/builder/ExprSessionAttributeBuilder; - public final fun build ()Lorg/partiql/ast/Expr$SessionAttribute; - public final fun getAttribute ()Lorg/partiql/ast/Expr$SessionAttribute$Attribute; - public final fun setAttribute (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)V -} - -public final class org/partiql/ast/builder/ExprSfwBuilder { - public fun ()V - public fun (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V - public synthetic fun (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/ast/Expr$SFW; - public final fun exclude (Lorg/partiql/ast/Exclude;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun from (Lorg/partiql/ast/From;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun getExclude ()Lorg/partiql/ast/Exclude; - public final fun getFrom ()Lorg/partiql/ast/From; - public final fun getGroupBy ()Lorg/partiql/ast/GroupBy; - public final fun getHaving ()Lorg/partiql/ast/Expr; - public final fun getLet ()Lorg/partiql/ast/Let; + public fun (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public synthetic fun (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun body (Lorg/partiql/ast/QueryBody;)Lorg/partiql/ast/builder/ExprQuerySetBuilder; + public final fun build ()Lorg/partiql/ast/Expr$QuerySet; + public final fun getBody ()Lorg/partiql/ast/QueryBody; public final fun getLimit ()Lorg/partiql/ast/Expr; public final fun getOffset ()Lorg/partiql/ast/Expr; public final fun getOrderBy ()Lorg/partiql/ast/OrderBy; - public final fun getSelect ()Lorg/partiql/ast/Select; - public final fun getSetOp ()Lorg/partiql/ast/Expr$SFW$SetOp; - public final fun getWhere ()Lorg/partiql/ast/Expr; - public final fun groupBy (Lorg/partiql/ast/GroupBy;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun having (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun let (Lorg/partiql/ast/Let;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun limit (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun offset (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun orderBy (Lorg/partiql/ast/OrderBy;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun select (Lorg/partiql/ast/Select;)Lorg/partiql/ast/builder/ExprSfwBuilder; - public final fun setExclude (Lorg/partiql/ast/Exclude;)V - public final fun setFrom (Lorg/partiql/ast/From;)V - public final fun setGroupBy (Lorg/partiql/ast/GroupBy;)V - public final fun setHaving (Lorg/partiql/ast/Expr;)V - public final fun setLet (Lorg/partiql/ast/Let;)V + public final fun limit (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprQuerySetBuilder; + public final fun offset (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprQuerySetBuilder; + public final fun orderBy (Lorg/partiql/ast/OrderBy;)Lorg/partiql/ast/builder/ExprQuerySetBuilder; + public final fun setBody (Lorg/partiql/ast/QueryBody;)V public final fun setLimit (Lorg/partiql/ast/Expr;)V public final fun setOffset (Lorg/partiql/ast/Expr;)V - public final fun setOp (Lorg/partiql/ast/Expr$SFW$SetOp;)Lorg/partiql/ast/builder/ExprSfwBuilder; public final fun setOrderBy (Lorg/partiql/ast/OrderBy;)V - public final fun setSelect (Lorg/partiql/ast/Select;)V - public final fun setSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;)V - public final fun setWhere (Lorg/partiql/ast/Expr;)V - public final fun where (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprSfwBuilder; } -public final class org/partiql/ast/builder/ExprSfwSetOpBuilder { +public final class org/partiql/ast/builder/ExprSessionAttributeBuilder { public fun ()V - public fun (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;)V - public synthetic fun (Lorg/partiql/ast/SetOp;Lorg/partiql/ast/Expr$SFW;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/ast/Expr$SFW$SetOp; - public final fun getOperand ()Lorg/partiql/ast/Expr$SFW; - public final fun getType ()Lorg/partiql/ast/SetOp; - public final fun operand (Lorg/partiql/ast/Expr$SFW;)Lorg/partiql/ast/builder/ExprSfwSetOpBuilder; - public final fun setOperand (Lorg/partiql/ast/Expr$SFW;)V - public final fun setType (Lorg/partiql/ast/SetOp;)V - public final fun type (Lorg/partiql/ast/SetOp;)Lorg/partiql/ast/builder/ExprSfwSetOpBuilder; + public fun (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)V + public synthetic fun (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun attribute (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)Lorg/partiql/ast/builder/ExprSessionAttributeBuilder; + public final fun build ()Lorg/partiql/ast/Expr$SessionAttribute; + public final fun getAttribute ()Lorg/partiql/ast/Expr$SessionAttribute$Attribute; + public final fun setAttribute (Lorg/partiql/ast/Expr$SessionAttribute$Attribute;)V } public final class org/partiql/ast/builder/ExprStructBuilder { @@ -5253,6 +5200,53 @@ public final class org/partiql/ast/builder/PathStepSymbolBuilder { public final fun symbol (Lorg/partiql/ast/Identifier$Symbol;)Lorg/partiql/ast/builder/PathStepSymbolBuilder; } +public final class org/partiql/ast/builder/QueryBodySetOpBuilder { + public fun ()V + public fun (Lorg/partiql/ast/SetOp;Ljava/lang/Boolean;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public synthetic fun (Lorg/partiql/ast/SetOp;Ljava/lang/Boolean;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/ast/QueryBody$SetOp; + public final fun getLhs ()Lorg/partiql/ast/Expr; + public final fun getRhs ()Lorg/partiql/ast/Expr; + public final fun getType ()Lorg/partiql/ast/SetOp; + public final fun isOuter ()Ljava/lang/Boolean; + public final fun isOuter (Ljava/lang/Boolean;)Lorg/partiql/ast/builder/QueryBodySetOpBuilder; + public final fun lhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/QueryBodySetOpBuilder; + public final fun rhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/QueryBodySetOpBuilder; + public final fun setLhs (Lorg/partiql/ast/Expr;)V + public final fun setOuter (Ljava/lang/Boolean;)V + public final fun setRhs (Lorg/partiql/ast/Expr;)V + public final fun setType (Lorg/partiql/ast/SetOp;)V + public final fun type (Lorg/partiql/ast/SetOp;)Lorg/partiql/ast/builder/QueryBodySetOpBuilder; +} + +public final class org/partiql/ast/builder/QueryBodySfwBuilder { + public fun ()V + public fun (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;)V + public synthetic fun (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/ast/QueryBody$SFW; + public final fun exclude (Lorg/partiql/ast/Exclude;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun from (Lorg/partiql/ast/From;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun getExclude ()Lorg/partiql/ast/Exclude; + public final fun getFrom ()Lorg/partiql/ast/From; + public final fun getGroupBy ()Lorg/partiql/ast/GroupBy; + public final fun getHaving ()Lorg/partiql/ast/Expr; + public final fun getLet ()Lorg/partiql/ast/Let; + public final fun getSelect ()Lorg/partiql/ast/Select; + public final fun getWhere ()Lorg/partiql/ast/Expr; + public final fun groupBy (Lorg/partiql/ast/GroupBy;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun having (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun let (Lorg/partiql/ast/Let;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun select (Lorg/partiql/ast/Select;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; + public final fun setExclude (Lorg/partiql/ast/Exclude;)V + public final fun setFrom (Lorg/partiql/ast/From;)V + public final fun setGroupBy (Lorg/partiql/ast/GroupBy;)V + public final fun setHaving (Lorg/partiql/ast/Expr;)V + public final fun setLet (Lorg/partiql/ast/Let;)V + public final fun setSelect (Lorg/partiql/ast/Select;)V + public final fun setWhere (Lorg/partiql/ast/Expr;)V + public final fun where (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/QueryBodySfwBuilder; +} + public final class org/partiql/ast/builder/ReturningBuilder { public fun ()V public fun (Ljava/util/List;)V @@ -6158,8 +6152,6 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/visitor/A public fun visitExcludeStepStructWildcard (Lorg/partiql/ast/Exclude$Step$StructWildcard;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprAnd (Lorg/partiql/ast/Expr$And;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprAnd (Lorg/partiql/ast/Expr$And;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; - public synthetic fun visitExprBagOp (Lorg/partiql/ast/Expr$BagOp;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprBagOp (Lorg/partiql/ast/Expr$BagOp;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprBetween (Lorg/partiql/ast/Expr$Between;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprBetween (Lorg/partiql/ast/Expr$Between;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprCall (Lorg/partiql/ast/Expr$Call;Ljava/lang/Object;)Ljava/lang/Object; @@ -6218,10 +6210,8 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/visitor/A public fun visitExprPathStepWildcard (Lorg/partiql/ast/Expr$Path$Step$Wildcard;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprPosition (Lorg/partiql/ast/Expr$Position;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprPosition (Lorg/partiql/ast/Expr$Position;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; - public synthetic fun visitExprSFW (Lorg/partiql/ast/Expr$SFW;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprSFW (Lorg/partiql/ast/Expr$SFW;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; - public synthetic fun visitExprSFWSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprSFWSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitExprQuerySet (Lorg/partiql/ast/Expr$QuerySet;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprQuerySet (Lorg/partiql/ast/Expr$QuerySet;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprStruct (Lorg/partiql/ast/Expr$Struct;Ljava/lang/Object;)Ljava/lang/Object; @@ -6265,6 +6255,10 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/visitor/A public fun visitPathStepIndex (Lorg/partiql/ast/Path$Step$Index;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitPathStepSymbol (Lorg/partiql/ast/Path$Step$Symbol;Ljava/lang/Object;)Ljava/lang/Object; public fun visitPathStepSymbol (Lorg/partiql/ast/Path$Step$Symbol;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitQueryBodySFW (Lorg/partiql/ast/QueryBody$SFW;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBodySFW (Lorg/partiql/ast/QueryBody$SFW;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitQueryBodySetOp (Lorg/partiql/ast/QueryBody$SetOp;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBodySetOp (Lorg/partiql/ast/QueryBody$SetOp;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitSelectPivot (Lorg/partiql/ast/Select$Pivot;Ljava/lang/Object;)Ljava/lang/Object; public fun visitSelectPivot (Lorg/partiql/ast/Select$Pivot;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitSelectProject (Lorg/partiql/ast/Select$Project;Ljava/lang/Object;)Ljava/lang/Object; @@ -6417,8 +6411,6 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitExcludeStepStructWildcard (Lorg/partiql/ast/Exclude$Step$StructWildcard;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprAnd (Lorg/partiql/ast/Expr$And;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprAnd (Lorg/partiql/ast/Expr$And;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; - public synthetic fun visitExprBagOp (Lorg/partiql/ast/Expr$BagOp;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprBagOp (Lorg/partiql/ast/Expr$BagOp;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprBetween (Lorg/partiql/ast/Expr$Between;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprBetween (Lorg/partiql/ast/Expr$Between;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprCall (Lorg/partiql/ast/Expr$Call;Ljava/lang/Object;)Ljava/lang/Object; @@ -6479,10 +6471,8 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitExprPathStepWildcard (Lorg/partiql/ast/Expr$Path$Step$Wildcard;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprPosition (Lorg/partiql/ast/Expr$Position;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprPosition (Lorg/partiql/ast/Expr$Position;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; - public synthetic fun visitExprSFW (Lorg/partiql/ast/Expr$SFW;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprSFW (Lorg/partiql/ast/Expr$SFW;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; - public synthetic fun visitExprSFWSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprSFWSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitExprQuerySet (Lorg/partiql/ast/Expr$QuerySet;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprQuerySet (Lorg/partiql/ast/Expr$QuerySet;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprStruct (Lorg/partiql/ast/Expr$Struct;Ljava/lang/Object;)Ljava/lang/Object; @@ -6573,6 +6563,10 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitPathStepIndex (Lorg/partiql/ast/Path$Step$Index;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitPathStepSymbol (Lorg/partiql/ast/Path$Step$Symbol;Ljava/lang/Object;)Ljava/lang/Object; public fun visitPathStepSymbol (Lorg/partiql/ast/Path$Step$Symbol;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitQueryBodySFW (Lorg/partiql/ast/QueryBody$SFW;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBodySFW (Lorg/partiql/ast/QueryBody$SFW;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitQueryBodySetOp (Lorg/partiql/ast/QueryBody$SetOp;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBodySetOp (Lorg/partiql/ast/QueryBody$SetOp;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitReturning (Lorg/partiql/ast/Returning;Ljava/lang/Object;)Ljava/lang/Object; public fun visitReturning (Lorg/partiql/ast/Returning;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitReturningColumn (Lorg/partiql/ast/Returning$Column;Ljava/lang/Object;)Ljava/lang/Object; @@ -6745,7 +6739,6 @@ public abstract class org/partiql/ast/visitor/AstBaseVisitor : org/partiql/ast/v public fun visitExcludeStepStructWildcard (Lorg/partiql/ast/Exclude$Step$StructWildcard;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExpr (Lorg/partiql/ast/Expr;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprAnd (Lorg/partiql/ast/Expr$And;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprBagOp (Lorg/partiql/ast/Expr$BagOp;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprBetween (Lorg/partiql/ast/Expr$Between;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprCall (Lorg/partiql/ast/Expr$Call;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprCanCast (Lorg/partiql/ast/Expr$CanCast;Ljava/lang/Object;)Ljava/lang/Object; @@ -6777,8 +6770,7 @@ public abstract class org/partiql/ast/visitor/AstBaseVisitor : org/partiql/ast/v public fun visitExprPathStepUnpivot (Lorg/partiql/ast/Expr$Path$Step$Unpivot;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprPathStepWildcard (Lorg/partiql/ast/Expr$Path$Step$Wildcard;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprPosition (Lorg/partiql/ast/Expr$Position;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprSFW (Lorg/partiql/ast/Expr$SFW;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprSFWSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprQuerySet (Lorg/partiql/ast/Expr$QuerySet;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprStruct (Lorg/partiql/ast/Expr$Struct;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprStructField (Lorg/partiql/ast/Expr$Struct$Field;Ljava/lang/Object;)Ljava/lang/Object; @@ -6832,6 +6824,9 @@ public abstract class org/partiql/ast/visitor/AstBaseVisitor : org/partiql/ast/v public fun visitPathStep (Lorg/partiql/ast/Path$Step;Ljava/lang/Object;)Ljava/lang/Object; public fun visitPathStepIndex (Lorg/partiql/ast/Path$Step$Index;Ljava/lang/Object;)Ljava/lang/Object; public fun visitPathStepSymbol (Lorg/partiql/ast/Path$Step$Symbol;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBody (Lorg/partiql/ast/QueryBody;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBodySFW (Lorg/partiql/ast/QueryBody$SFW;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitQueryBodySetOp (Lorg/partiql/ast/QueryBody$SetOp;Ljava/lang/Object;)Ljava/lang/Object; public fun visitReturning (Lorg/partiql/ast/Returning;Ljava/lang/Object;)Ljava/lang/Object; public fun visitReturningColumn (Lorg/partiql/ast/Returning$Column;Ljava/lang/Object;)Ljava/lang/Object; public fun visitReturningColumnValue (Lorg/partiql/ast/Returning$Column$Value;Ljava/lang/Object;)Ljava/lang/Object; @@ -6933,7 +6928,6 @@ public abstract interface class org/partiql/ast/visitor/AstVisitor { public abstract fun visitExcludeStepStructWildcard (Lorg/partiql/ast/Exclude$Step$StructWildcard;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExpr (Lorg/partiql/ast/Expr;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprAnd (Lorg/partiql/ast/Expr$And;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitExprBagOp (Lorg/partiql/ast/Expr$BagOp;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprBetween (Lorg/partiql/ast/Expr$Between;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprCall (Lorg/partiql/ast/Expr$Call;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprCanCast (Lorg/partiql/ast/Expr$CanCast;Ljava/lang/Object;)Ljava/lang/Object; @@ -6965,8 +6959,7 @@ public abstract interface class org/partiql/ast/visitor/AstVisitor { public abstract fun visitExprPathStepUnpivot (Lorg/partiql/ast/Expr$Path$Step$Unpivot;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprPathStepWildcard (Lorg/partiql/ast/Expr$Path$Step$Wildcard;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprPosition (Lorg/partiql/ast/Expr$Position;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitExprSFW (Lorg/partiql/ast/Expr$SFW;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitExprSFWSetOp (Lorg/partiql/ast/Expr$SFW$SetOp;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitExprQuerySet (Lorg/partiql/ast/Expr$QuerySet;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprSessionAttribute (Lorg/partiql/ast/Expr$SessionAttribute;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprStruct (Lorg/partiql/ast/Expr$Struct;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprStructField (Lorg/partiql/ast/Expr$Struct$Field;Ljava/lang/Object;)Ljava/lang/Object; @@ -7020,6 +7013,9 @@ public abstract interface class org/partiql/ast/visitor/AstVisitor { public abstract fun visitPathStep (Lorg/partiql/ast/Path$Step;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitPathStepIndex (Lorg/partiql/ast/Path$Step$Index;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitPathStepSymbol (Lorg/partiql/ast/Path$Step$Symbol;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitQueryBody (Lorg/partiql/ast/QueryBody;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitQueryBodySFW (Lorg/partiql/ast/QueryBody$SFW;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitQueryBodySetOp (Lorg/partiql/ast/QueryBody$SetOp;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitReturning (Lorg/partiql/ast/Returning;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitReturningColumn (Lorg/partiql/ast/Returning$Column;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitReturningColumnValue (Lorg/partiql/ast/Returning$Column$Value;Ljava/lang/Object;)Ljava/lang/Object; diff --git a/partiql-ast/src/main/kotlin/org/partiql/ast/helpers/ToLegacyAst.kt b/partiql-ast/src/main/kotlin/org/partiql/ast/helpers/ToLegacyAst.kt index dd1b84f433..c445eab9fb 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/helpers/ToLegacyAst.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/helpers/ToLegacyAst.kt @@ -27,6 +27,7 @@ import org.partiql.ast.Let import org.partiql.ast.OnConflict import org.partiql.ast.OrderBy import org.partiql.ast.Path +import org.partiql.ast.QueryBody import org.partiql.ast.Returning import org.partiql.ast.Select import org.partiql.ast.SetOp @@ -621,26 +622,6 @@ private class AstTranslator(val metas: Map) : AstBaseVisi call("date_diff", operands, metas) } - override fun visitExprBagOp(node: Expr.BagOp, ctx: Ctx) = translate(node) { metas -> - val lhs = visitExpr(node.lhs, ctx) - val rhs = visitExpr(node.rhs, ctx) - val op = when (node.outer) { - true -> when (node.type.type) { - SetOp.Type.UNION -> outerUnion() - SetOp.Type.INTERSECT -> outerIntersect() - SetOp.Type.EXCEPT -> outerExcept() - } - else -> when (node.type.type) { - SetOp.Type.UNION -> union() - SetOp.Type.INTERSECT -> intersect() - SetOp.Type.EXCEPT -> except() - } - } - val setq = node.type.setq?.toLegacySetQuantifier() ?: distinct() - val operands = listOf(lhs, rhs) - bagOp(op, setq, operands, metas) - } - override fun visitExprMatch(node: Expr.Match, ctx: Ctx) = translate(node) { metas -> val expr = visitExpr(node.expr, ctx) val match = visitGraphMatch(node.pattern, ctx) @@ -673,36 +654,62 @@ private class AstTranslator(val metas: Map) : AstBaseVisi /** * SELECT-FROM-WHERE */ - - override fun visitExprSFW(node: Expr.SFW, ctx: Ctx) = translate(node) { metas -> - var setq = when (val s = node.select) { - is Select.Pivot -> null - is Select.Project -> s.setq?.toLegacySetQuantifier() - is Select.Star -> s.setq?.toLegacySetQuantifier() - is Select.Value -> s.setq?.toLegacySetQuantifier() - } - // Legacy AST removes (setq (all)) - if (setq != null && setq is PartiqlAst.SetQuantifier.All) { - setq = null - } - val project = visitSelect(node.select, ctx) - val from = visitFrom(node.from, ctx) - val exclude = node.exclude?.let { visitExclude(it, ctx) } - val fromLet = node.let?.let { visitLet(it, ctx) } - val where = node.where?.let { visitExpr(it, ctx) } - val groupBy = node.groupBy?.let { visitGroupBy(it, ctx) } - val having = node.having?.let { visitExpr(it, ctx) } + override fun visitExprQuerySet(node: Expr.QuerySet, ctx: Ctx) = translate(node) { metas -> val orderBy = node.orderBy?.let { visitOrderBy(it, ctx) } val limit = node.limit?.let { visitExpr(it, ctx) } val offset = node.offset?.let { visitExpr(it, ctx) } - select(setq, project, exclude, from, fromLet, where, groupBy, having, orderBy, limit, offset, metas) + when (val body = node.body) { + is QueryBody.SFW -> { + var setq = when (val s = body.select) { + is Select.Pivot -> null + is Select.Project -> s.setq?.toLegacySetQuantifier() + is Select.Star -> s.setq?.toLegacySetQuantifier() + is Select.Value -> s.setq?.toLegacySetQuantifier() + } + // Legacy AST removes (setq (all)) + if (setq != null && setq is PartiqlAst.SetQuantifier.All) { + setq = null + } + val project = visitSelect(body.select, ctx) + val from = visitFrom(body.from, ctx) + val exclude = body.exclude?.let { visitExclude(it, ctx) } + val fromLet = body.let?.let { visitLet(it, ctx) } + val where = body.where?.let { visitExpr(it, ctx) } + val groupBy = body.groupBy?.let { visitGroupBy(it, ctx) } + val having = body.having?.let { visitExpr(it, ctx) } + select(setq, project, exclude, from, fromLet, where, groupBy, having, orderBy, limit, offset, metas) + } + is QueryBody.SetOp -> { + val lhs = visitExpr(body.lhs, ctx) + val rhs = visitExpr(body.rhs, ctx) + val outer = body.isOuter + val op = when (body.type.type) { + SetOp.Type.UNION -> if (outer) { + outerUnion() + } else { + union() + } + SetOp.Type.INTERSECT -> if (outer) { + outerIntersect() + } else { + intersect() + } + SetOp.Type.EXCEPT -> if (outer) { + outerExcept() + } else { + except() + } + } + val setq = body.type.setq?.toLegacySetQuantifier() ?: distinct() + val operands = listOf(lhs, rhs) + bagOp(op, setq, operands, metas) + } + } } /** * UNSUPPORTED in legacy AST */ - override fun visitExprSFWSetOp(node: Expr.SFW.SetOp, ctx: Ctx) = defaultVisit(node, ctx) - override fun visitSelect(node: Select, ctx: Ctx) = super.visitSelect(node, ctx) as PartiqlAst.Projection override fun visitSelectStar(node: Select.Star, ctx: Ctx) = translate(node) { metas -> diff --git a/partiql-ast/src/main/kotlin/org/partiql/ast/normalize/NormalizeFromSource.kt b/partiql-ast/src/main/kotlin/org/partiql/ast/normalize/NormalizeFromSource.kt index 8c12807ef6..69a46beb8f 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/normalize/NormalizeFromSource.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/normalize/NormalizeFromSource.kt @@ -17,6 +17,7 @@ package org.partiql.ast.normalize import org.partiql.ast.AstNode import org.partiql.ast.Expr import org.partiql.ast.From +import org.partiql.ast.QueryBody import org.partiql.ast.Statement import org.partiql.ast.fromJoin import org.partiql.ast.helpers.toBinder @@ -32,7 +33,7 @@ internal object NormalizeFromSource : AstPass { private object Visitor : AstRewriter() { // Each SFW starts the ctx count again. - override fun visitExprSFW(node: Expr.SFW, ctx: Int): AstNode = super.visitExprSFW(node, 0) + override fun visitQueryBodySFW(node: QueryBody.SFW, ctx: Int): AstNode = super.visitQueryBodySFW(node, 0) override fun visitStatementDMLBatchLegacy(node: Statement.DML.BatchLegacy, ctx: Int): AstNode = super.visitStatementDMLBatchLegacy(node, 0) diff --git a/partiql-ast/src/main/kotlin/org/partiql/ast/sql/SqlDialect.kt b/partiql-ast/src/main/kotlin/org/partiql/ast/sql/SqlDialect.kt index 0b3b180437..dced1e13e2 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/sql/SqlDialect.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/sql/SqlDialect.kt @@ -9,6 +9,7 @@ import org.partiql.ast.Identifier import org.partiql.ast.Let import org.partiql.ast.OrderBy import org.partiql.ast.Path +import org.partiql.ast.QueryBody import org.partiql.ast.Select import org.partiql.ast.SetOp import org.partiql.ast.SetQuantifier @@ -57,10 +58,10 @@ public abstract class SqlDialect : AstBaseVisitor() { * @param head */ public open fun visitExprWrapped(node: Expr, head: SqlBlock): SqlBlock = when (node) { - is Expr.SFW -> { + is Expr.QuerySet -> { var h = head h = h concat "(" - h = visitExprSFW(node, h) + h = visitExpr(node, h) h = h concat ")" h } @@ -552,33 +553,22 @@ public abstract class SqlDialect : AstBaseVisitor() { return h } - override fun visitExprBagOp(node: Expr.BagOp, head: SqlBlock): SqlBlock { - // [OUTER] [UNION|INTERSECT|EXCEPT] [ALL|DISTINCT] - val op = mutableListOf() - when (node.outer) { - true -> op.add("OUTER") - else -> {} - } - when (node.type.type) { - SetOp.Type.UNION -> op.add("UNION") - SetOp.Type.INTERSECT -> op.add("INTERSECT") - SetOp.Type.EXCEPT -> op.add("EXCEPT") - } - when (node.type.setq) { - SetQuantifier.ALL -> op.add("ALL") - SetQuantifier.DISTINCT -> op.add("DISTINCT") - null -> {} - } + override fun visitExprQuerySet(node: Expr.QuerySet, head: SqlBlock): SqlBlock { var h = head - h = visitExprWrapped(node.lhs, h) - h = h concat r(" ${op.joinToString(" ")} ") - h = visitExprWrapped(node.rhs, h) + // visit body (SFW or other SQL set op) + h = visit(node.body, h) + // ORDER BY + h = if (node.orderBy != null) visitOrderBy(node.orderBy, h concat r(" ")) else h + // LIMIT + h = if (node.limit != null) visitExprWrapped(node.limit, h concat r(" LIMIT ")) else h + // OFFSET + h = if (node.offset != null) visitExprWrapped(node.offset, h concat r(" OFFSET ")) else h return h } // SELECT-FROM-WHERE - override fun visitExprSFW(node: Expr.SFW, head: SqlBlock): SqlBlock { + override fun visitQueryBodySFW(node: QueryBody.SFW, head: SqlBlock): SqlBlock { var h = head // SELECT h = visit(node.select, h) @@ -594,14 +584,29 @@ public abstract class SqlDialect : AstBaseVisitor() { h = if (node.groupBy != null) visitGroupBy(node.groupBy, h concat r(" ")) else h // HAVING h = if (node.having != null) visitExprWrapped(node.having, h concat r(" HAVING ")) else h - // SET OP - h = if (node.setOp != null) visitExprSFWSetOp(node.setOp, h concat r(" ")) else h - // ORDER BY - h = if (node.orderBy != null) visitOrderBy(node.orderBy, h concat r(" ")) else h - // LIMIT - h = if (node.limit != null) visitExprWrapped(node.limit, h concat r(" LIMIT ")) else h - // OFFSET - h = if (node.offset != null) visitExprWrapped(node.offset, h concat r(" OFFSET ")) else h + return h + } + + override fun visitQueryBodySetOp(node: QueryBody.SetOp, head: SqlBlock): SqlBlock { + val op = mutableListOf() + when (node.isOuter) { + true -> op.add("OUTER") + else -> {} + } + when (node.type.type) { + SetOp.Type.UNION -> op.add("UNION") + SetOp.Type.INTERSECT -> op.add("INTERSECT") + SetOp.Type.EXCEPT -> op.add("EXCEPT") + } + when (node.type.setq) { + SetQuantifier.ALL -> op.add("ALL") + SetQuantifier.DISTINCT -> op.add("DISTINCT") + null -> {} + } + var h = head + h = visitExprWrapped(node.lhs, h) + h = h concat r(" ${op.joinToString(" ")} ") + h = visitExprWrapped(node.rhs, h) return h } @@ -736,17 +741,6 @@ public abstract class SqlDialect : AstBaseVisitor() { return head concat r(op) } - override fun visitExprSFWSetOp(node: Expr.SFW.SetOp, head: SqlBlock): SqlBlock { - var h = head - h = visitSetOp(node.type, h) - h = h concat r(" ") - h = h concat r("(") - val subquery = visitExprSFW(node.operand, SqlBlock.Nil) - h = h concat SqlBlock.Nest(subquery) - h = h concat r(")") - return h - } - // ORDER BY override fun visitOrderBy(node: OrderBy, head: SqlBlock): SqlBlock = head concat list("ORDER BY ", "") { node.sorts } diff --git a/partiql-ast/src/main/kotlin/org/partiql/ast/sql/internal/InternalSqlDialect.kt b/partiql-ast/src/main/kotlin/org/partiql/ast/sql/internal/InternalSqlDialect.kt index 225a359392..ca4692deb8 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/sql/internal/InternalSqlDialect.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/sql/internal/InternalSqlDialect.kt @@ -23,6 +23,7 @@ import org.partiql.ast.Identifier import org.partiql.ast.Let import org.partiql.ast.OrderBy import org.partiql.ast.Path +import org.partiql.ast.QueryBody import org.partiql.ast.Select import org.partiql.ast.SetOp import org.partiql.ast.SetQuantifier @@ -75,10 +76,10 @@ internal abstract class InternalSqlDialect : AstBaseVisitor { + is Expr.QuerySet -> { var t = tail t = t concat "(" - t = visitExprSFW(node, t) + t = visit(node, t) t = t concat ")" t } @@ -577,10 +578,43 @@ internal abstract class InternalSqlDialect : AstBaseVisitor() - when (node.outer) { + when (node.isOuter) { true -> op.add("OUTER") else -> {} } @@ -601,35 +635,6 @@ internal abstract class InternalSqlDialect : AstBaseVisitor` query expression, think SQL `` - s_f_w::{ - select: select, // oneof SELECT / SELECT VALUE / PIVOT - exclude: optional::exclude, - from: from, - let: optional::let, - where: optional::expr, - group_by: optional::group_by, - having: optional::expr, - set_op: optional::{ - type: '.set_op', - operand: '.expr.s_f_w', - }, + query_set::{ + body: query_body, order_by: optional::order_by, limit: optional::expr, offset: optional::expr, @@ -530,6 +511,27 @@ expr::[ }, ] +query_body::[ + // The PartiQL `` query expression, think SQL `` + s_f_w::{ + select: select, // oneof SELECT / SELECT VALUE / PIVOT + exclude: optional::exclude, + from: from, + let: optional::let, + where: optional::expr, + group_by: optional::group_by, + having: optional::expr, + }, + + // PartiQL bag op / SQL set op [OUTER] (UNION|INTERSECT|EXCEPT) [ALL|DISTINCT]` + set_op::{ + type: '.set_op', + is_outer: bool, + lhs: expr, + rhs: expr, + } +] + // PartiQL SELECT Clause Variants — https://partiql.org/dql/select.html select::[ diff --git a/partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt b/partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt index 997f6f7b21..51fb433ee1 100644 --- a/partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt +++ b/partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt @@ -924,48 +924,56 @@ class SqlDialectTest { rhs = v("y") } }, - expect("x UNION y") { - exprBagOp { - type = setOp { - type = SetOp.Type.UNION - setq = null + expect("x OUTER UNION y") { + exprQuerySet { + body = queryBodySetOp { + type = setOp { + type = SetOp.Type.UNION + setq = null + } + isOuter = true + lhs = v("x") + rhs = v("y") } - outer = false - lhs = v("x") - rhs = v("y") } }, - expect("x UNION ALL y") { - exprBagOp { - type = setOp { - type = SetOp.Type.UNION - setq = SetQuantifier.ALL + expect("x OUTER UNION ALL y") { + exprQuerySet { + body = queryBodySetOp { + type = setOp { + type = SetOp.Type.UNION + setq = SetQuantifier.ALL + } + isOuter = true + lhs = v("x") + rhs = v("y") } - outer = false - lhs = v("x") - rhs = v("y") } }, expect("x OUTER UNION y") { - exprBagOp { - type = setOp { - type = SetOp.Type.UNION - setq = null + exprQuerySet { + body = queryBodySetOp { + type = setOp { + type = SetOp.Type.UNION + setq = null + } + isOuter = true + lhs = v("x") + rhs = v("y") } - outer = true - lhs = v("x") - rhs = v("y") } }, expect("x OUTER UNION ALL y") { - exprBagOp { - type = setOp { - type = SetOp.Type.UNION - setq = SetQuantifier.ALL + exprQuerySet { + body = queryBodySetOp { + type = setOp { + type = SetOp.Type.UNION + setq = SetQuantifier.ALL + } + isOuter = true + lhs = v("x") + rhs = v("y") } - outer = true - lhs = v("x") - rhs = v("y") } }, ) @@ -997,104 +1005,130 @@ class SqlDialectTest { @JvmStatic fun selectClauseCases() = listOf( expect("SELECT a FROM T") { - exprSFW { - select = selectProject { - items += selectProjectItemExpression(v("a")) + exprQuerySet { + body = queryBodySFW { + select = selectProject { + items += selectProjectItemExpression(v("a")) + } + from = table("T") } - from = table("T") } }, expect("SELECT a AS x FROM T") { - exprSFW { - select = selectProject { - items += selectProjectItemExpression(v("a"), id("x")) + exprQuerySet { + body = queryBodySFW { + select = selectProject { + items += selectProjectItemExpression(v("a"), id("x")) + } + from = table("T") } - from = table("T") } }, expect("SELECT a AS x, b AS y FROM T") { - exprSFW { - select = selectProject { - items += selectProjectItemExpression(v("a"), id("x")) - items += selectProjectItemExpression(v("b"), id("y")) + exprQuerySet { + body = queryBodySFW { + select = selectProject { + items += selectProjectItemExpression(v("a"), id("x")) + items += selectProjectItemExpression(v("b"), id("y")) + } + from = table("T") } - from = table("T") } }, expect("SELECT ALL a FROM T") { - exprSFW { - select = selectProject { - setq = SetQuantifier.ALL - items += selectProjectItemExpression(v("a")) + exprQuerySet { + body = queryBodySFW { + select = selectProject { + setq = SetQuantifier.ALL + items += selectProjectItemExpression(v("a")) + } + from = table("T") } - from = table("T") } }, expect("SELECT DISTINCT a FROM T") { - exprSFW { - select = selectProject { - setq = SetQuantifier.DISTINCT - items += selectProjectItemExpression(v("a")) + exprQuerySet { + body = queryBodySFW { + select = selectProject { + setq = SetQuantifier.DISTINCT + items += selectProjectItemExpression(v("a")) + } + from = table("T") } - from = table("T") } }, expect("SELECT a.* FROM T") { - exprSFW { - select = selectProject { - items += selectProjectItemAll(v("a")) + exprQuerySet { + body = queryBodySFW { + select = selectProject { + items += selectProjectItemAll(v("a")) + } + from = table("T") } - from = table("T") } }, expect("SELECT * FROM T") { - exprSFW { - select = selectStar() - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = selectStar() + from = table("T") + } } }, expect("SELECT DISTINCT * FROM T") { - exprSFW { - select = selectStar(SetQuantifier.DISTINCT) - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = selectStar(SetQuantifier.DISTINCT) + from = table("T") + } } }, expect("SELECT ALL * FROM T") { - exprSFW { - select = selectStar(SetQuantifier.ALL) - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = selectStar(SetQuantifier.ALL) + from = table("T") + } } }, expect("SELECT VALUE a FROM T") { - exprSFW { - select = selectValue { - constructor = v("a") + exprQuerySet { + body = queryBodySFW { + select = selectValue { + constructor = v("a") + } + from = table("T") } - from = table("T") } }, expect("SELECT ALL VALUE a FROM T") { - exprSFW { - select = selectValue { - setq = SetQuantifier.ALL - constructor = v("a") + exprQuerySet { + body = queryBodySFW { + select = selectValue { + setq = SetQuantifier.ALL + constructor = v("a") + } + from = table("T") } - from = table("T") } }, expect("SELECT DISTINCT VALUE a FROM T") { - exprSFW { - select = selectValue { - setq = SetQuantifier.DISTINCT - constructor = v("a") + exprQuerySet { + body = queryBodySFW { + select = selectValue { + setq = SetQuantifier.DISTINCT + constructor = v("a") + } + from = table("T") } - from = table("T") } }, expect("PIVOT a AT b FROM T") { - exprSFW { - select = selectPivot(v("a"), v("b")) - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = selectPivot(v("a"), v("b")) + from = table("T") + } } }, ) @@ -1102,75 +1136,81 @@ class SqlDialectTest { @JvmStatic fun excludeClauseCases() = listOf( expect("SELECT a EXCLUDE t.a FROM T") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN - } - exclude = exclude { - items += excludeItem { - root = v("t") - steps += insensitiveExcludeStructField("a") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN + } + exclude = exclude { + items += excludeItem { + root = v("t") + steps += insensitiveExcludeStructField("a") + } } } } }, expect("SELECT a EXCLUDE a.b, c.d, e.f, g.h FROM T") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN - } - exclude = exclude { - items += excludeItem { - root = v("a") - steps += insensitiveExcludeStructField("b") - } - items += excludeItem { - root = v("c") - steps += insensitiveExcludeStructField("d") - } - items += excludeItem { - root = v("e") - steps += insensitiveExcludeStructField("f") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN } - items += excludeItem { - root = v("g") - steps += insensitiveExcludeStructField("h") + exclude = exclude { + items += excludeItem { + root = v("a") + steps += insensitiveExcludeStructField("b") + } + items += excludeItem { + root = v("c") + steps += insensitiveExcludeStructField("d") + } + items += excludeItem { + root = v("e") + steps += insensitiveExcludeStructField("f") + } + items += excludeItem { + root = v("g") + steps += insensitiveExcludeStructField("h") + } } } } }, expect("SELECT a EXCLUDE t.a.\"b\".*[*].c, \"s\"[0].d.\"e\"[*].f.* FROM T") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN - } - exclude = exclude { - items += excludeItem { - root = v("t") - steps += mutableListOf( - insensitiveExcludeStructField("a"), - sensitiveExcludeStructField("b"), - excludeStepStructWildcard(), - excludeStepCollWildcard(), - insensitiveExcludeStructField("c"), - ) - } - items += excludeItem { - root = exprVar(id("s", Identifier.CaseSensitivity.SENSITIVE), Expr.Var.Scope.DEFAULT) - steps += mutableListOf( - excludeStepCollIndex(0), - insensitiveExcludeStructField("d"), - sensitiveExcludeStructField("e"), - excludeStepCollWildcard(), - insensitiveExcludeStructField("f"), - excludeStepStructWildcard(), - ) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN + } + exclude = exclude { + items += excludeItem { + root = v("t") + steps += mutableListOf( + insensitiveExcludeStructField("a"), + sensitiveExcludeStructField("b"), + excludeStepStructWildcard(), + excludeStepCollWildcard(), + insensitiveExcludeStructField("c"), + ) + } + items += excludeItem { + root = exprVar(id("s", Identifier.CaseSensitivity.SENSITIVE), Expr.Var.Scope.DEFAULT) + steps += mutableListOf( + excludeStepCollIndex(0), + insensitiveExcludeStructField("d"), + sensitiveExcludeStructField("e"), + excludeStepCollWildcard(), + insensitiveExcludeStructField("f"), + excludeStepStructWildcard(), + ) + } } } } @@ -1188,86 +1228,102 @@ class SqlDialectTest { @JvmStatic fun fromClauseCases() = listOf( expect("SELECT a FROM T") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN + } } } }, expect("SELECT a FROM T AS x") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN - asAlias = id("x") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN + asAlias = id("x") + } } } }, expect("SELECT a FROM T AS x AT y") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN - asAlias = id("x") - atAlias = id("y") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN + asAlias = id("x") + atAlias = id("y") + } } } }, expect("SELECT a FROM T AS x AT y BY z") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.SCAN - asAlias = id("x") - atAlias = id("y") - byAlias = id("z") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.SCAN + asAlias = id("x") + atAlias = id("y") + byAlias = id("z") + } } } }, expect("SELECT a FROM UNPIVOT T") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.UNPIVOT + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.UNPIVOT + } } } }, expect("SELECT a FROM UNPIVOT T AS x") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.UNPIVOT - asAlias = id("x") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.UNPIVOT + asAlias = id("x") + } } } }, expect("SELECT a FROM UNPIVOT T AS x AT y") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.UNPIVOT - asAlias = id("x") - atAlias = id("y") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.UNPIVOT + asAlias = id("x") + atAlias = id("y") + } } } }, expect("SELECT a FROM UNPIVOT T AS x AT y BY z") { - exprSFW { - select = select("a") - from = fromValue { - expr = v("T") - type = From.Value.Type.UNPIVOT - asAlias = id("x") - atAlias = id("y") - byAlias = id("z") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromValue { + expr = v("T") + type = From.Value.Type.UNPIVOT + asAlias = id("x") + atAlias = id("y") + byAlias = id("z") + } } } }, @@ -1276,21 +1332,25 @@ class SqlDialectTest { @JvmStatic fun joinClauseCases() = listOf( expect("SELECT a FROM T JOIN S") { - exprSFW { - select = select("a") - from = fromJoin { - lhs = table("T") - rhs = table("S") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromJoin { + lhs = table("T") + rhs = table("S") + } } } }, expect("SELECT a FROM T INNER JOIN S") { - exprSFW { - select = select("a") - from = fromJoin { - type = From.Join.Type.INNER - lhs = table("T") - rhs = table("S") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromJoin { + type = From.Join.Type.INNER + lhs = table("T") + rhs = table("S") + } } } }, @@ -1315,23 +1375,27 @@ class SqlDialectTest { // } // }, expect("SELECT a FROM T JOIN S ON NULL") { - exprSFW { - select = select("a") - from = fromJoin { - lhs = table("T") - rhs = table("S") - condition = NULL + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromJoin { + lhs = table("T") + rhs = table("S") + condition = NULL + } } } }, expect("SELECT a FROM T INNER JOIN S ON NULL") { - exprSFW { - select = select("a") - from = fromJoin { - type = From.Join.Type.INNER - lhs = table("T") - rhs = table("S") - condition = NULL + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = fromJoin { + type = From.Join.Type.INNER + lhs = table("T") + rhs = table("S") + condition = NULL + } } } }, @@ -1341,62 +1405,76 @@ class SqlDialectTest { @JvmStatic private fun otherClausesCases() = listOf( expect("SELECT a FROM T LET x AS i") { - exprSFW { - select = select("a") - from = table("T") - let = let(mutableListOf()) { - bindings += letBinding(v("x"), id("i")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + let = let(mutableListOf()) { + bindings += letBinding(v("x"), id("i")) + } } } }, expect("SELECT a FROM T LET x AS i, y AS j") { - exprSFW { - select = select("a") - from = table("T") - let = let(mutableListOf()) { - bindings += letBinding(v("x"), id("i")) - bindings += letBinding(v("y"), id("j")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + let = let(mutableListOf()) { + bindings += letBinding(v("x"), id("i")) + bindings += letBinding(v("y"), id("j")) + } } } }, expect("SELECT a FROM T WHERE x") { - exprSFW { - select = select("a") - from = table("T") - where = v("x") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + where = v("x") + } } }, expect("SELECT a FROM T LIMIT 1") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } limit = exprLit(int32Value(1)) } }, expect("SELECT a FROM T OFFSET 2") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } offset = exprLit(int32Value(2)) } }, expect("SELECT a FROM T LIMIT 1 OFFSET 2") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } limit = exprLit(int32Value(1)) offset = exprLit(int32Value(2)) } }, expect("SELECT a FROM T GROUP BY x HAVING y") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x")) + } + having = v("y") } - having = v("y") } }, ) @@ -1404,100 +1482,118 @@ class SqlDialectTest { @JvmStatic private fun groupByClauseCases() = listOf( expect("SELECT a FROM T GROUP BY x") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x")) + } } } }, expect("SELECT a FROM T GROUP BY x AS i") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x"), id("i")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x"), id("i")) + } } } }, expect("SELECT a FROM T GROUP BY x, y") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x")) - keys += groupByKey(v("y")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x")) + keys += groupByKey(v("y")) + } } } }, expect("SELECT a FROM T GROUP BY x AS i, y AS j") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x"), id("i")) - keys += groupByKey(v("y"), id("j")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x"), id("i")) + keys += groupByKey(v("y"), id("j")) + } } } }, expect("SELECT a FROM T GROUP BY x GROUP AS g") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x")) - asAlias = id("g") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x")) + asAlias = id("g") + } } } }, expect("SELECT a FROM T GROUP BY x AS i GROUP AS g") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x"), id("i")) - asAlias = id("g") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x"), id("i")) + asAlias = id("g") + } } } }, expect("SELECT a FROM T GROUP BY x, y GROUP AS g") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x")) - keys += groupByKey(v("y")) - asAlias = id("g") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x")) + keys += groupByKey(v("y")) + asAlias = id("g") + } } } }, expect("SELECT a FROM T GROUP BY x AS i, y AS j GROUP AS g") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.FULL - keys += groupByKey(v("x"), id("i")) - keys += groupByKey(v("y"), id("j")) - asAlias = id("g") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.FULL + keys += groupByKey(v("x"), id("i")) + keys += groupByKey(v("y"), id("j")) + asAlias = id("g") + } } } }, expect("SELECT a FROM T GROUP PARTIAL BY x") { - exprSFW { - select = select("a") - from = table("T") - groupBy = groupBy { - strategy = GroupBy.Strategy.PARTIAL - keys += groupByKey(v("x")) + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + groupBy = groupBy { + strategy = GroupBy.Strategy.PARTIAL + keys += groupByKey(v("x")) + } } } }, @@ -1506,90 +1602,110 @@ class SqlDialectTest { @JvmStatic private fun orderByClauseCases() = listOf( expect("SELECT a FROM T ORDER BY x") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), null, null) } } }, expect("SELECT a FROM T ORDER BY x ASC") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.ASC, null) } } }, expect("SELECT a FROM T ORDER BY x DESC") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.DESC, null) } } }, expect("SELECT a FROM T ORDER BY x NULLS FIRST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), null, Sort.Nulls.FIRST) } } }, expect("SELECT a FROM T ORDER BY x NULLS LAST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), null, Sort.Nulls.LAST) } } }, expect("SELECT a FROM T ORDER BY x ASC NULLS FIRST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.ASC, Sort.Nulls.FIRST) } } }, expect("SELECT a FROM T ORDER BY x ASC NULLS LAST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.ASC, Sort.Nulls.LAST) } } }, expect("SELECT a FROM T ORDER BY x DESC NULLS FIRST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.DESC, Sort.Nulls.FIRST) } } }, expect("SELECT a FROM T ORDER BY x DESC NULLS LAST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.DESC, Sort.Nulls.LAST) } } }, expect("SELECT a FROM T ORDER BY x, y") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), null, null) sorts += sort(v("y"), null, null) @@ -1597,9 +1713,11 @@ class SqlDialectTest { } }, expect("SELECT a FROM T ORDER BY x ASC, y DESC") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.ASC, null) sorts += sort(v("y"), Sort.Dir.DESC, null) @@ -1607,9 +1725,11 @@ class SqlDialectTest { } }, expect("SELECT a FROM T ORDER BY x NULLS FIRST, y NULLS LAST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), null, Sort.Nulls.FIRST) sorts += sort(v("y"), null, Sort.Nulls.LAST) @@ -1617,9 +1737,11 @@ class SqlDialectTest { } }, expect("SELECT a FROM T ORDER BY x ASC NULLS FIRST, y DESC NULLS LAST") { - exprSFW { - select = select("a") - from = table("T") + exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } orderBy = orderBy { sorts += sort(v("x"), Sort.Dir.ASC, Sort.Nulls.FIRST) sorts += sort(v("y"), Sort.Dir.DESC, Sort.Nulls.LAST) @@ -1630,100 +1752,216 @@ class SqlDialectTest { @JvmStatic fun unionClauseCases() = listOf( - expect("SELECT a FROM T UNION (SELECT b FROM S)") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { - type = setOp(SetOp.Type.UNION, null) - operand = exprSFW { - select = select("b") - from = table("S") + expect("(SELECT a FROM T) UNION (SELECT b FROM S)") { + exprQuerySet { + body = queryBodySetOp { + type = setOp { + type = SetOp.Type.UNION + setq = null + } + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } } } } }, - expect("SELECT a FROM T UNION ALL (SELECT b FROM S)") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { + expect("(SELECT a FROM T) UNION ALL (SELECT b FROM S)") { + exprQuerySet { + body = queryBodySetOp { type = setOp(SetOp.Type.UNION, SetQuantifier.ALL) - operand = exprSFW { - select = select("b") - from = table("S") + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } } } } }, - expect("SELECT a FROM T UNION DISTINCT (SELECT b FROM S)") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { + expect("(SELECT a FROM T) UNION DISTINCT (SELECT b FROM S)") { + exprQuerySet { + body = queryBodySetOp { type = setOp(SetOp.Type.UNION, SetQuantifier.DISTINCT) - operand = exprSFW { - select = select("b") - from = table("S") + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } } } } }, - expect("SELECT a FROM T UNION (SELECT b FROM S) LIMIT 1") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { + expect("(SELECT a FROM T) UNION (SELECT b FROM S) LIMIT 1") { + exprQuerySet { + body = queryBodySetOp { type = setOp(SetOp.Type.UNION, null) - operand = exprSFW { - select = select("b") - from = table("S") + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } } } - limit = exprLit(int32Value(1)) + limit = exprLit(int32Value(1)) // LIMIT associated with SQL set op } }, - expect("SELECT a FROM T UNION (SELECT b FROM S LIMIT 1)") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { + expect("(SELECT a FROM T) UNION (SELECT b FROM S LIMIT 1)") { + exprQuerySet { + body = queryBodySetOp { type = setOp(SetOp.Type.UNION, null) - operand = exprSFW { - select = select("b") - from = table("S") - limit = exprLit(int32Value(1)) + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + limit = exprLit(int32Value(1)) // LIMIT associated with rhs SFW query + } } } } }, - expect("SELECT a FROM T UNION (SELECT b FROM S) ORDER BY x") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { + expect("(SELECT a FROM T) UNION (SELECT b FROM S) ORDER BY x") { + exprQuerySet { + body = queryBodySetOp { type = setOp(SetOp.Type.UNION, null) - operand = exprSFW { - select = select("b") - from = table("S") + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } } } orderBy = orderBy { - sorts += sort(v("x"), null, null) + sorts += sort(v("x"), null, null) // ORDER BY associated with SQL set op + } + } + }, + expect("(SELECT a FROM T) UNION (SELECT b FROM S ORDER BY x)") { + exprQuerySet { + body = queryBodySetOp { + type = setOp(SetOp.Type.UNION, null) + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + orderBy = orderBy { + sorts += sort(v("x"), null, null) // ORDER BY associated with SFW + } + } + } + } + } + }, + expect("(SELECT a FROM T) UNION ((SELECT b FROM S) UNION (SELECT c FROM R))") { + exprQuerySet { + body = queryBodySetOp { + type = setOp(SetOp.Type.UNION, null) + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySetOp { + type = setOp(SetOp.Type.UNION, null) + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("c") + from = table("R") + } + } + } + } } } }, - expect("SELECT a FROM T UNION (SELECT b FROM S ORDER BY x)") { - exprSFW { - select = select("a") - from = table("T") - setOp = exprSFWSetOp { + expect("((SELECT a FROM T) UNION (SELECT b FROM S)) UNION (SELECT c FROM R)") { + exprQuerySet { + body = queryBodySetOp { type = setOp(SetOp.Type.UNION, null) - operand = exprSFW { - select = select("b") - from = table("S") - orderBy = orderBy { - sorts += sort(v("x"), null, null) + isOuter = false + lhs = exprQuerySet { + body = queryBodySetOp { + type = setOp(SetOp.Type.UNION, null) + isOuter = false + lhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("b") + from = table("S") + } + } + } + } + rhs = exprQuerySet { + body = queryBodySFW { + select = select("c") + from = table("R") } } } @@ -1738,9 +1976,11 @@ class SqlDialectTest { exprOperator { symbol = "=" lhs = exprLit(int32Value(1)) - rhs = exprSFW { - select = select("a") - from = table("T") + rhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } } } }, @@ -1752,9 +1992,11 @@ class SqlDialectTest { values += exprLit(int32Value(1)) values += exprLit(int32Value(2)) } - rhs = exprSFW { - select = select("a") - from = table("T") + rhs = exprQuerySet { + body = queryBodySFW { + select = select("a") + from = table("T") + } } } }, diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/Compiler.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/Compiler.kt index b225b50b78..506b6a72aa 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/Compiler.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/Compiler.kt @@ -55,13 +55,13 @@ import org.partiql.plan.PlanNode import org.partiql.plan.Ref import org.partiql.plan.Rel import org.partiql.plan.Rex +import org.partiql.plan.SetQuantifier import org.partiql.plan.Statement import org.partiql.plan.debug.PlanPrinter import org.partiql.plan.visitor.PlanBaseVisitor import org.partiql.spi.fn.Agg import org.partiql.types.PType import org.partiql.value.PartiQLValueExperimental -import java.lang.IllegalStateException internal class Compiler( private val plan: PartiQLPlan, @@ -185,9 +185,9 @@ internal class Compiler( override fun visitRelOpAggregateCall(node: Rel.Op.Aggregate.Call, ctx: PType?): Operator.Aggregation { val args = node.args.map { visitRex(it, it.type).modeHandled() } - val setQuantifier: Operator.Aggregation.SetQuantifier = when (node.setQuantifier) { - Rel.Op.Aggregate.Call.SetQuantifier.ALL -> Operator.Aggregation.SetQuantifier.ALL - Rel.Op.Aggregate.Call.SetQuantifier.DISTINCT -> Operator.Aggregation.SetQuantifier.DISTINCT + val setQuantifier: Operator.Aggregation.SetQuantifier = when (node.setq) { + SetQuantifier.ALL -> Operator.Aggregation.SetQuantifier.ALL + SetQuantifier.DISTINCT -> Operator.Aggregation.SetQuantifier.DISTINCT } val agg = symbols.getAgg(node.agg) return object : Operator.Aggregation { @@ -304,30 +304,30 @@ internal class Compiler( } } - override fun visitRelOpSetExcept(node: Rel.Op.Set.Except, ctx: PType?): Operator { + override fun visitRelOpExcept(node: Rel.Op.Except, ctx: PType?): Operator { val lhs = visitRel(node.lhs, ctx) val rhs = visitRel(node.rhs, ctx) - return when (node.quantifier) { - Rel.Op.Set.Quantifier.ALL -> RelExceptAll(lhs, rhs) - Rel.Op.Set.Quantifier.DISTINCT -> RelExceptDistinct(lhs, rhs) + return when (node.setq) { + SetQuantifier.ALL -> RelExceptAll(lhs, rhs) + SetQuantifier.DISTINCT -> RelExceptDistinct(lhs, rhs) } } - override fun visitRelOpSetIntersect(node: Rel.Op.Set.Intersect, ctx: PType?): Operator { + override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: PType?): Operator { val lhs = visitRel(node.lhs, ctx) val rhs = visitRel(node.rhs, ctx) - return when (node.quantifier) { - Rel.Op.Set.Quantifier.ALL -> RelIntersectAll(lhs, rhs) - Rel.Op.Set.Quantifier.DISTINCT -> RelIntersectDistinct(lhs, rhs) + return when (node.setq) { + SetQuantifier.ALL -> RelIntersectAll(lhs, rhs) + SetQuantifier.DISTINCT -> RelIntersectDistinct(lhs, rhs) } } - override fun visitRelOpSetUnion(node: Rel.Op.Set.Union, ctx: PType?): Operator { + override fun visitRelOpUnion(node: Rel.Op.Union, ctx: PType?): Operator { val lhs = visitRel(node.lhs, ctx) val rhs = visitRel(node.rhs, ctx) - return when (node.quantifier) { - Rel.Op.Set.Quantifier.ALL -> RelUnionAll(lhs, rhs) - Rel.Op.Set.Quantifier.DISTINCT -> RelUnionDistinct(lhs, rhs) + return when (node.setq) { + SetQuantifier.ALL -> RelUnionAll(lhs, rhs) + SetQuantifier.DISTINCT -> RelUnionDistinct(lhs, rhs) } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordUtility.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordUtility.kt index 263ae7fb88..bb01076d16 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordUtility.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordUtility.kt @@ -1,12 +1,18 @@ package org.partiql.eval.internal.helpers -import org.partiql.eval.internal.Record -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental +import org.partiql.eval.value.Datum internal object RecordUtility { - @OptIn(PartiQLValueExperimental::class) - fun Record.toPartiQLValueList(): List = List(this.values.size) { - this.values[it].toPartiQLValue() + /** + * Coerces missing values into null values. Currently used when the [Datum.comparator] is used in a TreeSet/TreeMap + * (treats null and missing as the same value) and we need to deterministically return a value. Here we use coerce + * to null to follow the PartiQL spec's grouping function. + */ + fun Array.coerceMissing() { + for (i in indices) { + if (this[i].isMissing) { + this[i] = Datum.nullValue() + } + } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToBag.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToBag.kt deleted file mode 100644 index e77747f168..0000000000 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToBag.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.partiql.eval.internal.helpers - -import org.partiql.value.BagValue -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental - -/** - * Coercion function F for bag operators described in RFC-0007 - * - F(absent_value) -> << >> - * - F(scalar_value) -> << scalar_value >> # singleton bag - * - F(tuple_value) -> << tuple_value >> # singleton bag, see future extensions - * - F(array_value) -> bag_value # discard ordering - * - F(bag_value) -> bag_value # identity - */ -@OptIn(PartiQLValueExperimental::class) -internal fun PartiQLValue.toBag(): BagValue<*> { - TODO("For OUTER set operators") -} diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt index ffb96d2149..03c5b11cc6 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt @@ -2,22 +2,19 @@ package org.partiql.eval.internal.operator.rel import org.partiql.eval.internal.Environment import org.partiql.eval.internal.Record -import org.partiql.eval.internal.helpers.RecordUtility.toPartiQLValueList +import org.partiql.eval.internal.helpers.RecordUtility.coerceMissing import org.partiql.eval.internal.operator.Operator -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental +import org.partiql.eval.value.Datum +import java.util.TreeMap internal class RelExceptAll( private val lhs: Operator.Relation, private val rhs: Operator.Relation, ) : RelPeeking() { - // TODO: Add support for equals/hashcode in PQLValue - @OptIn(PartiQLValueExperimental::class) - private val seen: MutableMap, Int> = mutableMapOf() + private val seen = TreeMap, Int>(DatumArrayComparator) private var init: Boolean = false - @OptIn(PartiQLValueExperimental::class) override fun openPeeking(env: Environment) { lhs.open(env) rhs.open(env) @@ -25,24 +22,22 @@ internal class RelExceptAll( seen.clear() } - @OptIn(PartiQLValueExperimental::class) override fun peek(): Record? { if (!init) { seed() } for (row in lhs) { - val partiqlRow = row.toPartiQLValueList() - val remaining = seen[partiqlRow] ?: 0 + row.values.coerceMissing() + val remaining = seen[row.values] ?: 0 if (remaining > 0) { - seen[partiqlRow] = remaining - 1 + seen[row.values] = remaining - 1 continue } - return row + return Record(row.values) } return null } - @OptIn(PartiQLValueExperimental::class) override fun closePeeking() { lhs.close() rhs.close() @@ -52,13 +47,12 @@ internal class RelExceptAll( /** * Read the entire right-hand-side into our search structure. */ - @OptIn(PartiQLValueExperimental::class) private fun seed() { init = true for (row in rhs) { - val partiqlRow = row.toPartiQLValueList() - val n = seen[partiqlRow] ?: 0 - seen[partiqlRow] = n + 1 + row.values.coerceMissing() + val n = seen[row.values] ?: 0 + seen[row.values] = n + 1 } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptDistinct.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptDistinct.kt index 0fc2809532..fdda85bd36 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptDistinct.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptDistinct.kt @@ -2,10 +2,9 @@ package org.partiql.eval.internal.operator.rel import org.partiql.eval.internal.Environment import org.partiql.eval.internal.Record -import org.partiql.eval.internal.helpers.RecordUtility.toPartiQLValueList +import org.partiql.eval.internal.helpers.RecordUtility.coerceMissing import org.partiql.eval.internal.operator.Operator -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental +import java.util.TreeSet /** * Non-communicative, this performs better when [lhs] is larger than [rhs]. @@ -18,34 +17,28 @@ internal class RelExceptDistinct( private val rhs: Operator.Relation, ) : RelPeeking() { - // TODO: Add support for equals/hashcode in PQLValue - @OptIn(PartiQLValueExperimental::class) - private var seen: MutableSet> = mutableSetOf() + private var seen = TreeSet(DatumArrayComparator) private var init: Boolean = false - @OptIn(PartiQLValueExperimental::class) override fun openPeeking(env: Environment) { lhs.open(env) rhs.open(env) init = false - seen = mutableSetOf() } - @OptIn(PartiQLValueExperimental::class) override fun peek(): Record? { if (!init) { seed() } for (row in lhs) { - val partiqlRow = row.toPartiQLValueList() - if (!seen.contains(partiqlRow)) { - return row + row.values.coerceMissing() + if (!seen.contains(row.values)) { + return Record(row.values) } } return null } - @OptIn(PartiQLValueExperimental::class) override fun closePeeking() { lhs.close() rhs.close() @@ -55,12 +48,11 @@ internal class RelExceptDistinct( /** * Read the entire right-hand-side into our search structure. */ - @OptIn(PartiQLValueExperimental::class) private fun seed() { init = true for (row in rhs) { - val partiqlRow = row.toPartiQLValueList() - seen.add(partiqlRow) + row.values.coerceMissing() + seen.add(row.values) } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectAll.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectAll.kt index 70e94f46e6..294dc183ae 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectAll.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectAll.kt @@ -2,22 +2,19 @@ package org.partiql.eval.internal.operator.rel import org.partiql.eval.internal.Environment import org.partiql.eval.internal.Record -import org.partiql.eval.internal.helpers.RecordUtility.toPartiQLValueList +import org.partiql.eval.internal.helpers.RecordUtility.coerceMissing import org.partiql.eval.internal.operator.Operator -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental +import org.partiql.eval.value.Datum +import java.util.TreeMap internal class RelIntersectAll( private val lhs: Operator.Relation, private val rhs: Operator.Relation, ) : RelPeeking() { - // TODO: Add support for equals/hashcode in PQLValue - @OptIn(PartiQLValueExperimental::class) - private val seen: MutableMap, Int> = mutableMapOf() + private val seen = TreeMap, Int>(DatumArrayComparator) private var init: Boolean = false - @OptIn(PartiQLValueExperimental::class) override fun openPeeking(env: Environment) { lhs.open(env) rhs.open(env) @@ -25,23 +22,21 @@ internal class RelIntersectAll( seen.clear() } - @OptIn(PartiQLValueExperimental::class) override fun peek(): Record? { if (!init) { seed() } for (row in rhs) { - val partiqlRow = row.toPartiQLValueList() - val remaining = seen[partiqlRow] ?: 0 + row.values.coerceMissing() + val remaining = seen[row.values] ?: 0 if (remaining > 0) { - seen[partiqlRow] = remaining - 1 - return row + seen[row.values] = remaining - 1 + return Record(row.values) } } return null } - @OptIn(PartiQLValueExperimental::class) override fun closePeeking() { lhs.close() rhs.close() @@ -51,13 +46,12 @@ internal class RelIntersectAll( /** * Read the entire left-hand-side into our search structure. */ - @OptIn(PartiQLValueExperimental::class) private fun seed() { init = true for (row in lhs) { - val partiqlRow = row.toPartiQLValueList() - val alreadySeen = seen[partiqlRow] ?: 0 - seen[partiqlRow] = alreadySeen + 1 + row.values.coerceMissing() + val alreadySeen = seen[row.values] ?: 0 + seen[row.values] = alreadySeen + 1 } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectDistinct.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectDistinct.kt index 4e17edb945..1ca876c6d5 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectDistinct.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelIntersectDistinct.kt @@ -2,22 +2,18 @@ package org.partiql.eval.internal.operator.rel import org.partiql.eval.internal.Environment import org.partiql.eval.internal.Record -import org.partiql.eval.internal.helpers.RecordUtility.toPartiQLValueList +import org.partiql.eval.internal.helpers.RecordUtility.coerceMissing import org.partiql.eval.internal.operator.Operator -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental +import java.util.TreeSet internal class RelIntersectDistinct( private val lhs: Operator.Relation, private val rhs: Operator.Relation, ) : RelPeeking() { - // TODO: Add support for equals/hashcode in PQLValue - @OptIn(PartiQLValueExperimental::class) - private val seen: MutableSet> = mutableSetOf() + private val seen = TreeSet(DatumArrayComparator) private var init: Boolean = false - @OptIn(PartiQLValueExperimental::class) override fun openPeeking(env: Environment) { lhs.open(env) rhs.open(env) @@ -25,36 +21,33 @@ internal class RelIntersectDistinct( seen.clear() } - @OptIn(PartiQLValueExperimental::class) override fun peek(): Record? { if (!init) { seed() } for (row in rhs) { - val partiqlRow = row.toPartiQLValueList() - if (seen.remove(partiqlRow)) { - return row + row.values.coerceMissing() + if (seen.remove(row.values)) { + return Record(row.values) } } return null } - @OptIn(PartiQLValueExperimental::class) override fun closePeeking() { lhs.close() rhs.close() seen.clear() } - @OptIn(PartiQLValueExperimental::class) /** * Read the entire left-hand-side into our search structure. */ private fun seed() { init = true for (row in lhs) { - val partiqlRow = row.toPartiQLValueList() - seen.add(partiqlRow) + row.values.coerceMissing() + seen.add(row.values) } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionAll.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionAll.kt index 663abadd23..ece7a8dde3 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionAll.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionAll.kt @@ -2,6 +2,7 @@ package org.partiql.eval.internal.operator.rel import org.partiql.eval.internal.Environment import org.partiql.eval.internal.Record +import org.partiql.eval.internal.helpers.RecordUtility.coerceMissing import org.partiql.eval.internal.operator.Operator internal class RelUnionAll( @@ -20,8 +21,16 @@ internal class RelUnionAll( override fun next(): Record { return when (lhs.hasNext()) { - true -> lhs.next() - false -> rhs.next() + true -> { + val record = lhs.next() + record.values.coerceMissing() + record + } + false -> { + val record = rhs.next() + record.values.coerceMissing() + record + } } } diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionDistinct.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionDistinct.kt index c16ef42d07..dea611d6b9 100644 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionDistinct.kt +++ b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelUnionDistinct.kt @@ -3,23 +3,19 @@ package org.partiql.eval.internal.operator.rel import org.partiql.eval.internal.Environment import org.partiql.eval.internal.Record import org.partiql.eval.internal.helpers.IteratorChain -import org.partiql.eval.internal.helpers.RecordUtility.toPartiQLValueList +import org.partiql.eval.internal.helpers.RecordUtility.coerceMissing import org.partiql.eval.internal.operator.Operator -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental +import java.util.TreeSet internal class RelUnionDistinct( private val lhs: Operator.Relation, private val rhs: Operator.Relation, ) : RelPeeking() { - // TODO: Add support for equals/hashcode in PQLValue - @OptIn(PartiQLValueExperimental::class) - private val seen: MutableSet> = mutableSetOf() + private val seen = TreeSet(DatumArrayComparator) private lateinit var input: Iterator - @OptIn(PartiQLValueExperimental::class) override fun openPeeking(env: Environment) { lhs.open(env) rhs.open(env) @@ -27,19 +23,17 @@ internal class RelUnionDistinct( input = IteratorChain(arrayOf(lhs, rhs)) } - @OptIn(PartiQLValueExperimental::class) override fun peek(): Record? { for (record in input) { - val partiqlRow = record.toPartiQLValueList() - if (!seen.contains(partiqlRow)) { - seen.add(partiqlRow) - return record + record.values.coerceMissing() + if (!seen.contains(record.values)) { + seen.add(record.values) + return Record(record.values) } } return null } - @OptIn(PartiQLValueExperimental::class) override fun closePeeking() { lhs.close() rhs.close() diff --git a/partiql-lang/src/main/kotlin/org/partiql/lang/prettyprint/QueryPrettyPrinter.kt b/partiql-lang/src/main/kotlin/org/partiql/lang/prettyprint/QueryPrettyPrinter.kt index ce4d31f479..4e40444a47 100644 --- a/partiql-lang/src/main/kotlin/org/partiql/lang/prettyprint/QueryPrettyPrinter.kt +++ b/partiql-lang/src/main/kotlin/org/partiql/lang/prettyprint/QueryPrettyPrinter.kt @@ -320,7 +320,14 @@ class QueryPrettyPrinter { is PartiqlAst.Expr.Or -> writeNAryOperator("OR", node.operands, sb, level) is PartiqlAst.Expr.InCollection -> writeNAryOperator("IN", node.operands, sb, level) is PartiqlAst.Expr.BagOp -> { - var name = node.op.javaClass.simpleName.toUpperCase().replace("_", " ") + var name = when (node.op) { + is PartiqlAst.BagOpType.Except -> "EXCEPT" + is PartiqlAst.BagOpType.Intersect -> "INTERSECT" + is PartiqlAst.BagOpType.Union -> "UNION" + is PartiqlAst.BagOpType.OuterExcept -> "OUTER EXCEPT" + is PartiqlAst.BagOpType.OuterIntersect -> "OUTER INTERSECT" + is PartiqlAst.BagOpType.OuterUnion -> "OUTER UNION" + } if (node.quantifier is PartiqlAst.SetQuantifier.All) { name += " ALL" } diff --git a/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt b/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt index 8b46c2aa18..86e3803c96 100644 --- a/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt +++ b/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt @@ -765,37 +765,34 @@ internal class PartiQLPigVisitor( * */ - override fun visitIntersect(ctx: PartiQLParser.IntersectContext) = PartiqlAst.build { + override fun visitBagOp(ctx: PartiQLParser.BagOpContext) = PartiqlAst.build { val lhs = visit(ctx.lhs) as PartiqlAst.Expr val rhs = visit(ctx.rhs) as PartiqlAst.Expr - val quantifier = if (ctx.ALL() != null) all() else distinct() - val (intersect, metas) = when (ctx.OUTER()) { - null -> intersect() to ctx.INTERSECT().getSourceMetaContainer() - else -> outerIntersect() to ctx.OUTER().getSourceMetaContainer() - } - bagOp(intersect, quantifier, listOf(lhs, rhs), metas) - } - - override fun visitExcept(ctx: PartiQLParser.ExceptContext) = PartiqlAst.build { - val lhs = visit(ctx.lhs) as PartiqlAst.Expr - val rhs = visit(ctx.rhs) as PartiqlAst.Expr - val quantifier = if (ctx.ALL() != null) all() else distinct() - val (except, metas) = when (ctx.OUTER()) { - null -> except() to ctx.EXCEPT().getSourceMetaContainer() - else -> outerExcept() to ctx.OUTER().getSourceMetaContainer() - } - bagOp(except, quantifier, listOf(lhs, rhs), metas) - } - - override fun visitUnion(ctx: PartiQLParser.UnionContext) = PartiqlAst.build { - val lhs = visit(ctx.lhs) as PartiqlAst.Expr - val rhs = visit(ctx.rhs) as PartiqlAst.Expr - val quantifier = if (ctx.ALL() != null) all() else distinct() - val (union, metas) = when (ctx.OUTER()) { - null -> union() to ctx.UNION().getSourceMetaContainer() - else -> outerUnion() to ctx.OUTER().getSourceMetaContainer() + val setq = when { + ctx.ALL() != null -> all() + ctx.DISTINCT() != null -> distinct() + else -> distinct() + } + val outer = ctx.OUTER() != null + val (op, metas) = when (ctx.op.type) { + PartiQLParser.UNION -> if (outer) { + outerUnion() to ctx.UNION().getSourceMetaContainer() + } else { + union() to ctx.UNION().getSourceMetaContainer() + } + PartiQLParser.INTERSECT -> if (outer) { + outerIntersect() to ctx.OUTER().getSourceMetaContainer() + } else { + intersect() to ctx.INTERSECT().getSourceMetaContainer() + } + PartiQLParser.EXCEPT -> if (outer) { + outerExcept() to ctx.OUTER().getSourceMetaContainer() + } else { + except() to ctx.EXCEPT().getSourceMetaContainer() + } + else -> error("Unsupported bag op token ${ctx.op}") } - bagOp(union, quantifier, listOf(lhs, rhs), metas) + bagOp(op, setq, listOf(lhs, rhs), metas) } /** diff --git a/partiql-parser/src/main/antlr/PartiQLParser.g4 b/partiql-parser/src/main/antlr/PartiQLParser.g4 index 6f70cdedac..7e0acde953 100644 --- a/partiql-parser/src/main/antlr/PartiQLParser.g4 +++ b/partiql-parser/src/main/antlr/PartiQLParser.g4 @@ -527,10 +527,11 @@ expr ; exprBagOp - : lhs=exprBagOp OUTER? EXCEPT (DISTINCT|ALL)? rhs=exprSelect # Except - | lhs=exprBagOp OUTER? UNION (DISTINCT|ALL)? rhs=exprSelect # Union - | lhs=exprBagOp OUTER? INTERSECT (DISTINCT|ALL)? rhs=exprSelect # Intersect - | exprSelect # QueryBase + : lhs=exprBagOp OUTER? op=(UNION | EXCEPT | INTERSECT) (DISTINCT|ALL)? rhs=exprSelect + order=orderByClause? + limit=limitClause? + offset=offsetByClause? # BagOp + | exprSelect # QueryBase ; exprSelect @@ -541,9 +542,9 @@ exprSelect where=whereClauseSelect? group=groupClause? having=havingClause? - order=orderByClause? - limit=limitClause? - offset=offsetByClause? # SfwQuery + order=orderByClause?? + limit=limitClause?? + offset=offsetByClause?? # SfwQuery | exprOr # SfwBase ; diff --git a/partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt b/partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt index 108367e393..60ec5cd2cd 100644 --- a/partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt +++ b/partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt @@ -58,7 +58,6 @@ import org.partiql.ast.excludeStepCollWildcard import org.partiql.ast.excludeStepStructField import org.partiql.ast.excludeStepStructWildcard import org.partiql.ast.exprAnd -import org.partiql.ast.exprBagOp import org.partiql.ast.exprBetween import org.partiql.ast.exprCall import org.partiql.ast.exprCanCast @@ -89,7 +88,7 @@ import org.partiql.ast.exprPathStepSymbol import org.partiql.ast.exprPathStepUnpivot import org.partiql.ast.exprPathStepWildcard import org.partiql.ast.exprPosition -import org.partiql.ast.exprSFW +import org.partiql.ast.exprQuerySet import org.partiql.ast.exprSessionAttribute import org.partiql.ast.exprStruct import org.partiql.ast.exprStructField @@ -133,6 +132,8 @@ import org.partiql.ast.orderBy import org.partiql.ast.path import org.partiql.ast.pathStepIndex import org.partiql.ast.pathStepSymbol +import org.partiql.ast.queryBodySFW +import org.partiql.ast.queryBodySetOp import org.partiql.ast.returning import org.partiql.ast.returningColumn import org.partiql.ast.returningColumnValueExpression @@ -934,12 +935,17 @@ internal class PartiQLParserDefault : PartiQLParser { val where = visitOrNull(ctx.where) val groupBy = ctx.group?.let { visitGroupClause(it) } val having = visitOrNull(ctx.having?.arg) - // TODO Add SQL UNION, INTERSECT, EXCEPT to PartiQL.g4 - val setOp: Expr.SFW.SetOp? = null val orderBy = ctx.order?.let { visitOrderByClause(it) } val limit = visitOrNull(ctx.limit?.arg) val offset = visitOrNull(ctx.offset?.arg) - exprSFW(select, exclude, from, let, where, groupBy, having, setOp, orderBy, limit, offset) + exprQuerySet( + body = queryBodySFW( + select, exclude, from, let, where, groupBy, having + ), + orderBy = orderBy, + limit = limit, + offset = offset + ) } /** @@ -1121,44 +1127,35 @@ internal class PartiQLParserDefault : PartiQLParser { * BAG OPERATIONS * */ - - override fun visitIntersect(ctx: GeneratedParser.IntersectContext) = translate(ctx) { + override fun visitBagOp(ctx: GeneratedParser.BagOpContext) = translate(ctx) { val setq = when { ctx.ALL() != null -> SetQuantifier.ALL ctx.DISTINCT() != null -> SetQuantifier.DISTINCT else -> null } - val op = setOp(SetOp.Type.INTERSECT, setq) - val lhs = visitAs(ctx.lhs) - val rhs = visitAs(ctx.rhs) - val outer = ctx.OUTER() != null - exprBagOp(op, lhs, rhs, outer) - } - - override fun visitExcept(ctx: GeneratedParser.ExceptContext) = translate(ctx) { - val setq = when { - ctx.ALL() != null -> SetQuantifier.ALL - ctx.DISTINCT() != null -> SetQuantifier.DISTINCT - else -> null + val op = when (ctx.op.type) { + GeneratedParser.UNION -> setOp(SetOp.Type.UNION, setq) + GeneratedParser.INTERSECT -> setOp(SetOp.Type.INTERSECT, setq) + GeneratedParser.EXCEPT -> setOp(SetOp.Type.EXCEPT, setq) + else -> error("Unsupported bag op token ${ctx.op}") } - val op = setOp(SetOp.Type.EXCEPT, setq) val lhs = visitAs(ctx.lhs) val rhs = visitAs(ctx.rhs) val outer = ctx.OUTER() != null - exprBagOp(op, lhs, rhs, outer) - } - - override fun visitUnion(ctx: GeneratedParser.UnionContext) = translate(ctx) { - val setq = when { - ctx.ALL() != null -> SetQuantifier.ALL - ctx.DISTINCT() != null -> SetQuantifier.DISTINCT - else -> null - } - val op = setOp(SetOp.Type.UNION, setq) - val lhs = visitAs(ctx.lhs) - val rhs = visitAs(ctx.rhs) - val outer = ctx.OUTER() != null - exprBagOp(op, lhs, rhs, outer) + val orderBy = ctx.order?.let { visitOrderByClause(it) } + val limit = ctx.limit?.let { visitAs(it) } + val offset = ctx.offset?.let { visitAs(it) } + exprQuerySet( + body = queryBodySetOp( + type = op, + isOuter = outer, + lhs = lhs, + rhs = rhs + ), + orderBy = orderBy, + limit = limit, + offset = offset, + ) } /** @@ -1559,7 +1556,7 @@ internal class PartiQLParserDefault : PartiQLParser { val lhs = visitAs(ctx.lhs) val rhs = visitAs(ctx.rhs ?: ctx.expr()).let { // Wrap rhs in an array unless it's a query or already a collection - if (it is Expr.SFW || it is Expr.Collection || ctx.PAREN_LEFT() == null) { + if (it is Expr.QuerySet || it is Expr.Collection || ctx.PAREN_LEFT() == null) { it } else { // IN ( expr ) diff --git a/partiql-plan/api/partiql-plan.api b/partiql-plan/api/partiql-plan.api index 05bf0115c8..c30b469f68 100644 --- a/partiql-plan/api/partiql-plan.api +++ b/partiql-plan/api/partiql-plan.api @@ -173,9 +173,10 @@ public final class org/partiql/plan/Plan { public static final fun rel (Lorg/partiql/plan/Rel$Type;Lorg/partiql/plan/Rel$Op;)Lorg/partiql/plan/Rel; public static final fun relBinding (Ljava/lang/String;Lorg/partiql/types/PType;)Lorg/partiql/plan/Rel$Binding; public static final fun relOpAggregate (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel$Op$Aggregate$Strategy;Ljava/util/List;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Aggregate; - public static final fun relOpAggregateCall (Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; + public static final fun relOpAggregateCall (Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; public static final fun relOpDistinct (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Distinct; public static final fun relOpErr (Ljava/lang/String;)Lorg/partiql/plan/Rel$Op$Err; + public static final fun relOpExcept (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Except; public static final fun relOpExclude (Lorg/partiql/plan/Rel;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Exclude; public static final fun relOpExcludePath (Lorg/partiql/plan/Rex$Op$Var;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Exclude$Path; public static final fun relOpExcludeStep (Lorg/partiql/plan/Rel$Op$Exclude$Type;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Exclude$Step; @@ -185,17 +186,16 @@ public final class org/partiql/plan/Plan { public static final fun relOpExcludeTypeStructSymbol (Ljava/lang/String;)Lorg/partiql/plan/Rel$Op$Exclude$Type$StructSymbol; public static final fun relOpExcludeTypeStructWildcard ()Lorg/partiql/plan/Rel$Op$Exclude$Type$StructWildcard; public static final fun relOpFilter (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;)Lorg/partiql/plan/Rel$Op$Filter; + public static final fun relOpIntersect (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Intersect; public static final fun relOpJoin (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Join$Type;)Lorg/partiql/plan/Rel$Op$Join; public static final fun relOpLimit (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;)Lorg/partiql/plan/Rel$Op$Limit; public static final fun relOpOffset (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;)Lorg/partiql/plan/Rel$Op$Offset; public static final fun relOpProject (Lorg/partiql/plan/Rel;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Project; public static final fun relOpScan (Lorg/partiql/plan/Rex;)Lorg/partiql/plan/Rel$Op$Scan; public static final fun relOpScanIndexed (Lorg/partiql/plan/Rex;)Lorg/partiql/plan/Rel$Op$ScanIndexed; - public static final fun relOpSetExcept (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Set$Except; - public static final fun relOpSetIntersect (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Set$Intersect; - public static final fun relOpSetUnion (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Set$Union; public static final fun relOpSort (Lorg/partiql/plan/Rel;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Sort; public static final fun relOpSortSpec (Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Sort$Order;)Lorg/partiql/plan/Rel$Op$Sort$Spec; + public static final fun relOpUnion (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Union; public static final fun relOpUnpivot (Lorg/partiql/plan/Rex;)Lorg/partiql/plan/Rel$Op$Unpivot; public static final fun relType (Ljava/util/List;Ljava/util/Set;)Lorg/partiql/plan/Rel$Type; public static final fun rex (Lorg/partiql/types/PType;Lorg/partiql/plan/Rex$Op;)Lorg/partiql/plan/Rex; @@ -347,15 +347,15 @@ public final class org/partiql/plan/Rel$Op$Aggregate$Call : org/partiql/plan/Pla public static final field Companion Lorg/partiql/plan/Rel$Op$Aggregate$Call$Companion; public final field agg Lorg/partiql/plan/Ref; public final field args Ljava/util/List; - public final field setQuantifier Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; - public fun (Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;)V + public final field setq Lorg/partiql/plan/SetQuantifier; + public fun (Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;)V public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static final fun builder ()Lorg/partiql/plan/builder/RelOpAggregateCallBuilder; public final fun component1 ()Lorg/partiql/plan/Ref; - public final fun component2 ()Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; + public final fun component2 ()Lorg/partiql/plan/SetQuantifier; public final fun component3 ()Ljava/util/List; - public final fun copy (Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; - public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Aggregate$Call;Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; + public final fun copy (Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; + public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Aggregate$Call;Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; public fun equals (Ljava/lang/Object;)Z public fun getChildren ()Ljava/util/List; public fun hashCode ()I @@ -366,13 +366,6 @@ public final class org/partiql/plan/Rel$Op$Aggregate$Call$Companion { public final fun builder ()Lorg/partiql/plan/builder/RelOpAggregateCallBuilder; } -public final class org/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier : java/lang/Enum { - public static final field ALL Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; - public static final field DISTINCT Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; - public static fun values ()[Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; -} - public final class org/partiql/plan/Rel$Op$Aggregate$Companion { public final fun builder ()Lorg/partiql/plan/builder/RelOpAggregateBuilder; } @@ -422,6 +415,29 @@ public final class org/partiql/plan/Rel$Op$Err$Companion { public final fun builder ()Lorg/partiql/plan/builder/RelOpErrBuilder; } +public final class org/partiql/plan/Rel$Op$Except : org/partiql/plan/Rel$Op { + public static final field Companion Lorg/partiql/plan/Rel$Op$Except$Companion; + public final field lhs Lorg/partiql/plan/Rel; + public final field rhs Lorg/partiql/plan/Rel; + public final field setq Lorg/partiql/plan/SetQuantifier; + public fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V + public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun builder ()Lorg/partiql/plan/builder/RelOpExceptBuilder; + public final fun component1 ()Lorg/partiql/plan/SetQuantifier; + public final fun component2 ()Lorg/partiql/plan/Rel; + public final fun component3 ()Lorg/partiql/plan/Rel; + public final fun copy (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Except; + public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Except;Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Except; + public fun equals (Ljava/lang/Object;)Z + public fun getChildren ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/partiql/plan/Rel$Op$Except$Companion { + public final fun builder ()Lorg/partiql/plan/builder/RelOpExceptBuilder; +} + public final class org/partiql/plan/Rel$Op$Exclude : org/partiql/plan/Rel$Op { public static final field Companion Lorg/partiql/plan/Rel$Op$Exclude$Companion; public final field input Lorg/partiql/plan/Rel; @@ -609,6 +625,29 @@ public final class org/partiql/plan/Rel$Op$Filter$Companion { public final fun builder ()Lorg/partiql/plan/builder/RelOpFilterBuilder; } +public final class org/partiql/plan/Rel$Op$Intersect : org/partiql/plan/Rel$Op { + public static final field Companion Lorg/partiql/plan/Rel$Op$Intersect$Companion; + public final field lhs Lorg/partiql/plan/Rel; + public final field rhs Lorg/partiql/plan/Rel; + public final field setq Lorg/partiql/plan/SetQuantifier; + public fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V + public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun builder ()Lorg/partiql/plan/builder/RelOpIntersectBuilder; + public final fun component1 ()Lorg/partiql/plan/SetQuantifier; + public final fun component2 ()Lorg/partiql/plan/Rel; + public final fun component3 ()Lorg/partiql/plan/Rel; + public final fun copy (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Intersect; + public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Intersect;Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Intersect; + public fun equals (Ljava/lang/Object;)Z + public fun getChildren ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/partiql/plan/Rel$Op$Intersect$Companion { + public final fun builder ()Lorg/partiql/plan/builder/RelOpIntersectBuilder; +} + public final class org/partiql/plan/Rel$Op$Join : org/partiql/plan/Rel$Op { public static final field Companion Lorg/partiql/plan/Rel$Op$Join$Companion; public final field lhs Lorg/partiql/plan/Rel; @@ -744,86 +783,6 @@ public final class org/partiql/plan/Rel$Op$ScanIndexed$Companion { public final fun builder ()Lorg/partiql/plan/builder/RelOpScanIndexedBuilder; } -public abstract class org/partiql/plan/Rel$Op$Set : org/partiql/plan/Rel$Op { - public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; -} - -public final class org/partiql/plan/Rel$Op$Set$Except : org/partiql/plan/Rel$Op$Set { - public static final field Companion Lorg/partiql/plan/Rel$Op$Set$Except$Companion; - public final field lhs Lorg/partiql/plan/Rel; - public final field quantifier Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final field rhs Lorg/partiql/plan/Rel; - public fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V - public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public static final fun builder ()Lorg/partiql/plan/builder/RelOpSetExceptBuilder; - public final fun component1 ()Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final fun component2 ()Lorg/partiql/plan/Rel; - public final fun component3 ()Lorg/partiql/plan/Rel; - public final fun copy (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Set$Except; - public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Set$Except;Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Set$Except; - public fun equals (Ljava/lang/Object;)Z - public fun getChildren ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/partiql/plan/Rel$Op$Set$Except$Companion { - public final fun builder ()Lorg/partiql/plan/builder/RelOpSetExceptBuilder; -} - -public final class org/partiql/plan/Rel$Op$Set$Intersect : org/partiql/plan/Rel$Op$Set { - public static final field Companion Lorg/partiql/plan/Rel$Op$Set$Intersect$Companion; - public final field lhs Lorg/partiql/plan/Rel; - public final field quantifier Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final field rhs Lorg/partiql/plan/Rel; - public fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V - public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public static final fun builder ()Lorg/partiql/plan/builder/RelOpSetIntersectBuilder; - public final fun component1 ()Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final fun component2 ()Lorg/partiql/plan/Rel; - public final fun component3 ()Lorg/partiql/plan/Rel; - public final fun copy (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Set$Intersect; - public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Set$Intersect;Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Set$Intersect; - public fun equals (Ljava/lang/Object;)Z - public fun getChildren ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/partiql/plan/Rel$Op$Set$Intersect$Companion { - public final fun builder ()Lorg/partiql/plan/builder/RelOpSetIntersectBuilder; -} - -public final class org/partiql/plan/Rel$Op$Set$Quantifier : java/lang/Enum { - public static final field ALL Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public static final field DISTINCT Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public static fun values ()[Lorg/partiql/plan/Rel$Op$Set$Quantifier; -} - -public final class org/partiql/plan/Rel$Op$Set$Union : org/partiql/plan/Rel$Op$Set { - public static final field Companion Lorg/partiql/plan/Rel$Op$Set$Union$Companion; - public final field lhs Lorg/partiql/plan/Rel; - public final field quantifier Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final field rhs Lorg/partiql/plan/Rel; - public fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V - public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public static final fun builder ()Lorg/partiql/plan/builder/RelOpSetUnionBuilder; - public final fun component1 ()Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final fun component2 ()Lorg/partiql/plan/Rel; - public final fun component3 ()Lorg/partiql/plan/Rel; - public final fun copy (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Set$Union; - public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Set$Union;Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Set$Union; - public fun equals (Ljava/lang/Object;)Z - public fun getChildren ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/partiql/plan/Rel$Op$Set$Union$Companion { - public final fun builder ()Lorg/partiql/plan/builder/RelOpSetUnionBuilder; -} - public final class org/partiql/plan/Rel$Op$Sort : org/partiql/plan/Rel$Op { public static final field Companion Lorg/partiql/plan/Rel$Op$Sort$Companion; public final field input Lorg/partiql/plan/Rel; @@ -875,6 +834,29 @@ public final class org/partiql/plan/Rel$Op$Sort$Spec$Companion { public final fun builder ()Lorg/partiql/plan/builder/RelOpSortSpecBuilder; } +public final class org/partiql/plan/Rel$Op$Union : org/partiql/plan/Rel$Op { + public static final field Companion Lorg/partiql/plan/Rel$Op$Union$Companion; + public final field lhs Lorg/partiql/plan/Rel; + public final field rhs Lorg/partiql/plan/Rel; + public final field setq Lorg/partiql/plan/SetQuantifier; + public fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V + public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun builder ()Lorg/partiql/plan/builder/RelOpUnionBuilder; + public final fun component1 ()Lorg/partiql/plan/SetQuantifier; + public final fun component2 ()Lorg/partiql/plan/Rel; + public final fun component3 ()Lorg/partiql/plan/Rel; + public final fun copy (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)Lorg/partiql/plan/Rel$Op$Union; + public static synthetic fun copy$default (Lorg/partiql/plan/Rel$Op$Union;Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Union; + public fun equals (Ljava/lang/Object;)Z + public fun getChildren ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/partiql/plan/Rel$Op$Union$Companion { + public final fun builder ()Lorg/partiql/plan/builder/RelOpUnionBuilder; +} + public final class org/partiql/plan/Rel$Op$Unpivot : org/partiql/plan/Rel$Op { public static final field Companion Lorg/partiql/plan/Rel$Op$Unpivot$Companion; public final field rex Lorg/partiql/plan/Rex; @@ -1436,6 +1418,13 @@ public final class org/partiql/plan/Rex$Op$Var$Companion { public final fun builder ()Lorg/partiql/plan/builder/RexOpVarBuilder; } +public final class org/partiql/plan/SetQuantifier : java/lang/Enum { + public static final field ALL Lorg/partiql/plan/SetQuantifier; + public static final field DISTINCT Lorg/partiql/plan/SetQuantifier; + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/plan/SetQuantifier; + public static fun values ()[Lorg/partiql/plan/SetQuantifier; +} + public abstract class org/partiql/plan/Statement : org/partiql/plan/PlanNode { public fun accept (Lorg/partiql/plan/visitor/PlanVisitor;Ljava/lang/Object;)Ljava/lang/Object; } @@ -1576,12 +1565,14 @@ public final class org/partiql/plan/builder/PlanBuilder { public static synthetic fun relBinding$default (Lorg/partiql/plan/builder/PlanBuilder;Ljava/lang/String;Lorg/partiql/types/PType;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Binding; public final fun relOpAggregate (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel$Op$Aggregate$Strategy;Ljava/util/List;Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Aggregate; public static synthetic fun relOpAggregate$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel$Op$Aggregate$Strategy;Ljava/util/List;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Aggregate; - public final fun relOpAggregateCall (Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; - public static synthetic fun relOpAggregateCall$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; + public final fun relOpAggregateCall (Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; + public static synthetic fun relOpAggregateCall$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Aggregate$Call; public final fun relOpDistinct (Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Distinct; public static synthetic fun relOpDistinct$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Distinct; public final fun relOpErr (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Err; public static synthetic fun relOpErr$default (Lorg/partiql/plan/builder/PlanBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Err; + public final fun relOpExcept (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Except; + public static synthetic fun relOpExcept$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Except; public final fun relOpExclude (Lorg/partiql/plan/Rel;Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Exclude; public static synthetic fun relOpExclude$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Exclude; public final fun relOpExcludePath (Lorg/partiql/plan/Rex$Op$Var;Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Exclude$Path; @@ -1600,6 +1591,8 @@ public final class org/partiql/plan/builder/PlanBuilder { public static synthetic fun relOpExcludeTypeStructWildcard$default (Lorg/partiql/plan/builder/PlanBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Exclude$Type$StructWildcard; public final fun relOpFilter (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Filter; public static synthetic fun relOpFilter$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Filter; + public final fun relOpIntersect (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Intersect; + public static synthetic fun relOpIntersect$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Intersect; public final fun relOpJoin (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Join$Type;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Join; public static synthetic fun relOpJoin$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Join$Type;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Join; public final fun relOpLimit (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Limit; @@ -1612,16 +1605,12 @@ public final class org/partiql/plan/builder/PlanBuilder { public static synthetic fun relOpScan$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Scan; public final fun relOpScanIndexed (Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$ScanIndexed; public static synthetic fun relOpScanIndexed$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$ScanIndexed; - public final fun relOpSetExcept (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Set$Except; - public static synthetic fun relOpSetExcept$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Set$Except; - public final fun relOpSetIntersect (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Set$Intersect; - public static synthetic fun relOpSetIntersect$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Set$Intersect; - public final fun relOpSetUnion (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Set$Union; - public static synthetic fun relOpSetUnion$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Set$Union; public final fun relOpSort (Lorg/partiql/plan/Rel;Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Sort; public static synthetic fun relOpSort$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rel;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Sort; public final fun relOpSortSpec (Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Sort$Order;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Sort$Spec; public static synthetic fun relOpSortSpec$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Sort$Order;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Sort$Spec; + public final fun relOpUnion (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Union; + public static synthetic fun relOpUnion$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Union; public final fun relOpUnpivot (Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Op$Unpivot; public static synthetic fun relOpUnpivot$default (Lorg/partiql/plan/builder/PlanBuilder;Lorg/partiql/plan/Rex;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/plan/Rel$Op$Unpivot; public final fun relType (Ljava/util/List;Ljava/util/Set;Lkotlin/jvm/functions/Function1;)Lorg/partiql/plan/Rel$Type; @@ -1758,18 +1747,18 @@ public final class org/partiql/plan/builder/RelOpAggregateBuilder { public final class org/partiql/plan/builder/RelOpAggregateCallBuilder { public fun ()V - public fun (Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;)V - public synthetic fun (Lorg/partiql/plan/Ref;Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;)V + public synthetic fun (Lorg/partiql/plan/Ref;Lorg/partiql/plan/SetQuantifier;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun agg (Lorg/partiql/plan/Ref;)Lorg/partiql/plan/builder/RelOpAggregateCallBuilder; public final fun args (Ljava/util/List;)Lorg/partiql/plan/builder/RelOpAggregateCallBuilder; public final fun build ()Lorg/partiql/plan/Rel$Op$Aggregate$Call; public final fun getAgg ()Lorg/partiql/plan/Ref; public final fun getArgs ()Ljava/util/List; - public final fun getSetQuantifier ()Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier; + public final fun getSetq ()Lorg/partiql/plan/SetQuantifier; public final fun setAgg (Lorg/partiql/plan/Ref;)V public final fun setArgs (Ljava/util/List;)V - public final fun setQuantifier (Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;)Lorg/partiql/plan/builder/RelOpAggregateCallBuilder; - public final fun setSetQuantifier (Lorg/partiql/plan/Rel$Op$Aggregate$Call$SetQuantifier;)V + public final fun setSetq (Lorg/partiql/plan/SetQuantifier;)V + public final fun setq (Lorg/partiql/plan/SetQuantifier;)Lorg/partiql/plan/builder/RelOpAggregateCallBuilder; } public final class org/partiql/plan/builder/RelOpDistinctBuilder { @@ -1792,6 +1781,22 @@ public final class org/partiql/plan/builder/RelOpErrBuilder { public final fun setMessage (Ljava/lang/String;)V } +public final class org/partiql/plan/builder/RelOpExceptBuilder { + public fun ()V + public fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V + public synthetic fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/plan/Rel$Op$Except; + public final fun getLhs ()Lorg/partiql/plan/Rel; + public final fun getRhs ()Lorg/partiql/plan/Rel; + public final fun getSetq ()Lorg/partiql/plan/SetQuantifier; + public final fun lhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpExceptBuilder; + public final fun rhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpExceptBuilder; + public final fun setLhs (Lorg/partiql/plan/Rel;)V + public final fun setRhs (Lorg/partiql/plan/Rel;)V + public final fun setSetq (Lorg/partiql/plan/SetQuantifier;)V + public final fun setq (Lorg/partiql/plan/SetQuantifier;)Lorg/partiql/plan/builder/RelOpExceptBuilder; +} + public final class org/partiql/plan/builder/RelOpExcludeBuilder { public fun ()V public fun (Lorg/partiql/plan/Rel;Ljava/util/List;)V @@ -1884,6 +1889,22 @@ public final class org/partiql/plan/builder/RelOpFilterBuilder { public final fun setPredicate (Lorg/partiql/plan/Rex;)V } +public final class org/partiql/plan/builder/RelOpIntersectBuilder { + public fun ()V + public fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V + public synthetic fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/plan/Rel$Op$Intersect; + public final fun getLhs ()Lorg/partiql/plan/Rel; + public final fun getRhs ()Lorg/partiql/plan/Rel; + public final fun getSetq ()Lorg/partiql/plan/SetQuantifier; + public final fun lhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpIntersectBuilder; + public final fun rhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpIntersectBuilder; + public final fun setLhs (Lorg/partiql/plan/Rel;)V + public final fun setRhs (Lorg/partiql/plan/Rel;)V + public final fun setSetq (Lorg/partiql/plan/SetQuantifier;)V + public final fun setq (Lorg/partiql/plan/SetQuantifier;)Lorg/partiql/plan/builder/RelOpIntersectBuilder; +} + public final class org/partiql/plan/builder/RelOpJoinBuilder { public fun ()V public fun (Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rex;Lorg/partiql/plan/Rel$Op$Join$Type;)V @@ -1962,54 +1983,6 @@ public final class org/partiql/plan/builder/RelOpScanIndexedBuilder { public final fun setRex (Lorg/partiql/plan/Rex;)V } -public final class org/partiql/plan/builder/RelOpSetExceptBuilder { - public fun ()V - public fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V - public synthetic fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/plan/Rel$Op$Set$Except; - public final fun getLhs ()Lorg/partiql/plan/Rel; - public final fun getQuantifier ()Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final fun getRhs ()Lorg/partiql/plan/Rel; - public final fun lhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpSetExceptBuilder; - public final fun quantifier (Lorg/partiql/plan/Rel$Op$Set$Quantifier;)Lorg/partiql/plan/builder/RelOpSetExceptBuilder; - public final fun rhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpSetExceptBuilder; - public final fun setLhs (Lorg/partiql/plan/Rel;)V - public final fun setQuantifier (Lorg/partiql/plan/Rel$Op$Set$Quantifier;)V - public final fun setRhs (Lorg/partiql/plan/Rel;)V -} - -public final class org/partiql/plan/builder/RelOpSetIntersectBuilder { - public fun ()V - public fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V - public synthetic fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/plan/Rel$Op$Set$Intersect; - public final fun getLhs ()Lorg/partiql/plan/Rel; - public final fun getQuantifier ()Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final fun getRhs ()Lorg/partiql/plan/Rel; - public final fun lhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpSetIntersectBuilder; - public final fun quantifier (Lorg/partiql/plan/Rel$Op$Set$Quantifier;)Lorg/partiql/plan/builder/RelOpSetIntersectBuilder; - public final fun rhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpSetIntersectBuilder; - public final fun setLhs (Lorg/partiql/plan/Rel;)V - public final fun setQuantifier (Lorg/partiql/plan/Rel$Op$Set$Quantifier;)V - public final fun setRhs (Lorg/partiql/plan/Rel;)V -} - -public final class org/partiql/plan/builder/RelOpSetUnionBuilder { - public fun ()V - public fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V - public synthetic fun (Lorg/partiql/plan/Rel$Op$Set$Quantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/plan/Rel$Op$Set$Union; - public final fun getLhs ()Lorg/partiql/plan/Rel; - public final fun getQuantifier ()Lorg/partiql/plan/Rel$Op$Set$Quantifier; - public final fun getRhs ()Lorg/partiql/plan/Rel; - public final fun lhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpSetUnionBuilder; - public final fun quantifier (Lorg/partiql/plan/Rel$Op$Set$Quantifier;)Lorg/partiql/plan/builder/RelOpSetUnionBuilder; - public final fun rhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpSetUnionBuilder; - public final fun setLhs (Lorg/partiql/plan/Rel;)V - public final fun setQuantifier (Lorg/partiql/plan/Rel$Op$Set$Quantifier;)V - public final fun setRhs (Lorg/partiql/plan/Rel;)V -} - public final class org/partiql/plan/builder/RelOpSortBuilder { public fun ()V public fun (Lorg/partiql/plan/Rel;Ljava/util/List;)V @@ -2036,6 +2009,22 @@ public final class org/partiql/plan/builder/RelOpSortSpecBuilder { public final fun setRex (Lorg/partiql/plan/Rex;)V } +public final class org/partiql/plan/builder/RelOpUnionBuilder { + public fun ()V + public fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;)V + public synthetic fun (Lorg/partiql/plan/SetQuantifier;Lorg/partiql/plan/Rel;Lorg/partiql/plan/Rel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/plan/Rel$Op$Union; + public final fun getLhs ()Lorg/partiql/plan/Rel; + public final fun getRhs ()Lorg/partiql/plan/Rel; + public final fun getSetq ()Lorg/partiql/plan/SetQuantifier; + public final fun lhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpUnionBuilder; + public final fun rhs (Lorg/partiql/plan/Rel;)Lorg/partiql/plan/builder/RelOpUnionBuilder; + public final fun setLhs (Lorg/partiql/plan/Rel;)V + public final fun setRhs (Lorg/partiql/plan/Rel;)V + public final fun setSetq (Lorg/partiql/plan/SetQuantifier;)V + public final fun setq (Lorg/partiql/plan/SetQuantifier;)Lorg/partiql/plan/builder/RelOpUnionBuilder; +} + public final class org/partiql/plan/builder/RelOpUnpivotBuilder { public fun ()V public fun (Lorg/partiql/plan/Rex;)V @@ -2409,6 +2398,8 @@ public abstract class org/partiql/plan/util/PlanRewriter : org/partiql/plan/visi public fun visitRelOpDistinct (Lorg/partiql/plan/Rel$Op$Distinct;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpErr (Lorg/partiql/plan/Rel$Op$Err;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpErr (Lorg/partiql/plan/Rel$Op$Err;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; + public synthetic fun visitRelOpExcept (Lorg/partiql/plan/Rel$Op$Except;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitRelOpExcept (Lorg/partiql/plan/Rel$Op$Except;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpExclude (Lorg/partiql/plan/Rel$Op$Exclude;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpExclude (Lorg/partiql/plan/Rel$Op$Exclude;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpExcludePath (Lorg/partiql/plan/Rel$Op$Exclude$Path;Ljava/lang/Object;)Ljava/lang/Object; @@ -2427,6 +2418,8 @@ public abstract class org/partiql/plan/util/PlanRewriter : org/partiql/plan/visi public fun visitRelOpExcludeTypeStructWildcard (Lorg/partiql/plan/Rel$Op$Exclude$Type$StructWildcard;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpFilter (Lorg/partiql/plan/Rel$Op$Filter;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpFilter (Lorg/partiql/plan/Rel$Op$Filter;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; + public synthetic fun visitRelOpIntersect (Lorg/partiql/plan/Rel$Op$Intersect;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitRelOpIntersect (Lorg/partiql/plan/Rel$Op$Intersect;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpJoin (Lorg/partiql/plan/Rel$Op$Join;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpJoin (Lorg/partiql/plan/Rel$Op$Join;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpLimit (Lorg/partiql/plan/Rel$Op$Limit;Ljava/lang/Object;)Ljava/lang/Object; @@ -2439,16 +2432,12 @@ public abstract class org/partiql/plan/util/PlanRewriter : org/partiql/plan/visi public fun visitRelOpScan (Lorg/partiql/plan/Rel$Op$Scan;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpScanIndexed (Lorg/partiql/plan/Rel$Op$ScanIndexed;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpScanIndexed (Lorg/partiql/plan/Rel$Op$ScanIndexed;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; - public synthetic fun visitRelOpSetExcept (Lorg/partiql/plan/Rel$Op$Set$Except;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSetExcept (Lorg/partiql/plan/Rel$Op$Set$Except;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; - public synthetic fun visitRelOpSetIntersect (Lorg/partiql/plan/Rel$Op$Set$Intersect;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSetIntersect (Lorg/partiql/plan/Rel$Op$Set$Intersect;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; - public synthetic fun visitRelOpSetUnion (Lorg/partiql/plan/Rel$Op$Set$Union;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSetUnion (Lorg/partiql/plan/Rel$Op$Set$Union;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpSort (Lorg/partiql/plan/Rel$Op$Sort;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpSort (Lorg/partiql/plan/Rel$Op$Sort;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpSortSpec (Lorg/partiql/plan/Rel$Op$Sort$Spec;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpSortSpec (Lorg/partiql/plan/Rel$Op$Sort$Spec;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; + public synthetic fun visitRelOpUnion (Lorg/partiql/plan/Rel$Op$Union;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitRelOpUnion (Lorg/partiql/plan/Rel$Op$Union;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelOpUnpivot (Lorg/partiql/plan/Rel$Op$Unpivot;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpUnpivot (Lorg/partiql/plan/Rel$Op$Unpivot;Ljava/lang/Object;)Lorg/partiql/plan/PlanNode; public synthetic fun visitRelType (Lorg/partiql/plan/Rel$Type;Ljava/lang/Object;)Ljava/lang/Object; @@ -3562,6 +3551,7 @@ public abstract class org/partiql/plan/visitor/PlanBaseVisitor : org/partiql/pla public fun visitRelOpAggregateCall (Lorg/partiql/plan/Rel$Op$Aggregate$Call;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpDistinct (Lorg/partiql/plan/Rel$Op$Distinct;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpErr (Lorg/partiql/plan/Rel$Op$Err;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitRelOpExcept (Lorg/partiql/plan/Rel$Op$Except;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpExclude (Lorg/partiql/plan/Rel$Op$Exclude;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpExcludePath (Lorg/partiql/plan/Rel$Op$Exclude$Path;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpExcludeStep (Lorg/partiql/plan/Rel$Op$Exclude$Step;Ljava/lang/Object;)Ljava/lang/Object; @@ -3572,18 +3562,16 @@ public abstract class org/partiql/plan/visitor/PlanBaseVisitor : org/partiql/pla public fun visitRelOpExcludeTypeStructSymbol (Lorg/partiql/plan/Rel$Op$Exclude$Type$StructSymbol;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpExcludeTypeStructWildcard (Lorg/partiql/plan/Rel$Op$Exclude$Type$StructWildcard;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpFilter (Lorg/partiql/plan/Rel$Op$Filter;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitRelOpIntersect (Lorg/partiql/plan/Rel$Op$Intersect;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpJoin (Lorg/partiql/plan/Rel$Op$Join;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpLimit (Lorg/partiql/plan/Rel$Op$Limit;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpOffset (Lorg/partiql/plan/Rel$Op$Offset;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpProject (Lorg/partiql/plan/Rel$Op$Project;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpScan (Lorg/partiql/plan/Rel$Op$Scan;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpScanIndexed (Lorg/partiql/plan/Rel$Op$ScanIndexed;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSet (Lorg/partiql/plan/Rel$Op$Set;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSetExcept (Lorg/partiql/plan/Rel$Op$Set$Except;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSetIntersect (Lorg/partiql/plan/Rel$Op$Set$Intersect;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitRelOpSetUnion (Lorg/partiql/plan/Rel$Op$Set$Union;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpSort (Lorg/partiql/plan/Rel$Op$Sort;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpSortSpec (Lorg/partiql/plan/Rel$Op$Sort$Spec;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitRelOpUnion (Lorg/partiql/plan/Rel$Op$Union;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelOpUnpivot (Lorg/partiql/plan/Rel$Op$Unpivot;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRelType (Lorg/partiql/plan/Rel$Type;Ljava/lang/Object;)Ljava/lang/Object; public fun visitRex (Lorg/partiql/plan/Rex;Ljava/lang/Object;)Ljava/lang/Object; @@ -3637,6 +3625,7 @@ public abstract interface class org/partiql/plan/visitor/PlanVisitor { public abstract fun visitRelOpAggregateCall (Lorg/partiql/plan/Rel$Op$Aggregate$Call;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpDistinct (Lorg/partiql/plan/Rel$Op$Distinct;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpErr (Lorg/partiql/plan/Rel$Op$Err;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitRelOpExcept (Lorg/partiql/plan/Rel$Op$Except;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpExclude (Lorg/partiql/plan/Rel$Op$Exclude;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpExcludePath (Lorg/partiql/plan/Rel$Op$Exclude$Path;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpExcludeStep (Lorg/partiql/plan/Rel$Op$Exclude$Step;Ljava/lang/Object;)Ljava/lang/Object; @@ -3647,18 +3636,16 @@ public abstract interface class org/partiql/plan/visitor/PlanVisitor { public abstract fun visitRelOpExcludeTypeStructSymbol (Lorg/partiql/plan/Rel$Op$Exclude$Type$StructSymbol;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpExcludeTypeStructWildcard (Lorg/partiql/plan/Rel$Op$Exclude$Type$StructWildcard;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpFilter (Lorg/partiql/plan/Rel$Op$Filter;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitRelOpIntersect (Lorg/partiql/plan/Rel$Op$Intersect;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpJoin (Lorg/partiql/plan/Rel$Op$Join;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpLimit (Lorg/partiql/plan/Rel$Op$Limit;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpOffset (Lorg/partiql/plan/Rel$Op$Offset;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpProject (Lorg/partiql/plan/Rel$Op$Project;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpScan (Lorg/partiql/plan/Rel$Op$Scan;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpScanIndexed (Lorg/partiql/plan/Rel$Op$ScanIndexed;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitRelOpSet (Lorg/partiql/plan/Rel$Op$Set;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitRelOpSetExcept (Lorg/partiql/plan/Rel$Op$Set$Except;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitRelOpSetIntersect (Lorg/partiql/plan/Rel$Op$Set$Intersect;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitRelOpSetUnion (Lorg/partiql/plan/Rel$Op$Set$Union;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpSort (Lorg/partiql/plan/Rel$Op$Sort;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpSortSpec (Lorg/partiql/plan/Rel$Op$Sort$Spec;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitRelOpUnion (Lorg/partiql/plan/Rel$Op$Union;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelOpUnpivot (Lorg/partiql/plan/Rel$Op$Unpivot;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRelType (Lorg/partiql/plan/Rel$Type;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitRex (Lorg/partiql/plan/Rex;Ljava/lang/Object;)Ljava/lang/Object; diff --git a/partiql-plan/src/main/resources/partiql_plan.ion b/partiql-plan/src/main/resources/partiql_plan.ion index 801234b5b8..6b909bee67 100644 --- a/partiql-plan/src/main/resources/partiql_plan.ion +++ b/partiql-plan/src/main/resources/partiql_plan.ion @@ -73,6 +73,12 @@ identifier::[ ], ] +// [ ALL | DISTINCT ] +set_quantifier::[ + ALL, + DISTINCT, +] + // Rex rex::{ type: static_type, @@ -261,29 +267,24 @@ rel::{ ], }, - set::[ - union::{ - quantifier: quantifier, - lhs: rel, - rhs: rel, - }, - - intersect::{ - quantifier: quantifier, - lhs: rel, - rhs: rel, - }, + // SQL set ops + union::{ + setq: set_quantifier, + lhs: rel, + rhs: rel, + }, - except::{ - quantifier: quantifier, - lhs: rel, - rhs: rel, - }, + intersect::{ + setq: set_quantifier, + lhs: rel, + rhs: rel, + }, - _::[ - quantifier::[ ALL, DISTINCT ], - ] - ], + except::{ + setq: set_quantifier, + lhs: rel, + rhs: rel, + }, limit::{ input: rel, @@ -322,7 +323,7 @@ rel::{ _: [ call::{ agg: ref, - set_quantifier: [ ALL, DISTINCT ], + setq: set_quantifier, args: list::[rex], }, ], diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt index ef5445cd3b..8196e6c850 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt @@ -10,6 +10,7 @@ import org.partiql.planner.internal.casts.Coercions import org.partiql.planner.internal.ir.Ref import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.Rex +import org.partiql.planner.internal.ir.SetQuantifier import org.partiql.planner.internal.ir.refAgg import org.partiql.planner.internal.ir.refFn import org.partiql.planner.internal.ir.relOpAggregateCallResolved @@ -161,7 +162,7 @@ internal class Env(private val session: Session) { } } - fun resolveAgg(path: String, setQuantifier: Rel.Op.Aggregate.SetQuantifier, args: List): Rel.Op.Aggregate.Call.Resolved? { + fun resolveAgg(path: String, setQuantifier: SetQuantifier, args: List): Rel.Op.Aggregate.Call.Resolved? { // TODO: Eventually, do we want to support sensitive lookup? With a path? val catalog = session.getCatalog() val name = path.lowercase() diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt index 7c502cd050..f6b90ae01e 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt @@ -19,6 +19,7 @@ import org.partiql.planner.internal.ir.builder.RelOpAggregateCallResolvedBuilder import org.partiql.planner.internal.ir.builder.RelOpAggregateCallUnresolvedBuilder import org.partiql.planner.internal.ir.builder.RelOpDistinctBuilder import org.partiql.planner.internal.ir.builder.RelOpErrBuilder +import org.partiql.planner.internal.ir.builder.RelOpExceptBuilder import org.partiql.planner.internal.ir.builder.RelOpExcludeBuilder import org.partiql.planner.internal.ir.builder.RelOpExcludePathBuilder import org.partiql.planner.internal.ir.builder.RelOpExcludeStepBuilder @@ -28,17 +29,16 @@ import org.partiql.planner.internal.ir.builder.RelOpExcludeTypeStructKeyBuilder import org.partiql.planner.internal.ir.builder.RelOpExcludeTypeStructSymbolBuilder import org.partiql.planner.internal.ir.builder.RelOpExcludeTypeStructWildcardBuilder import org.partiql.planner.internal.ir.builder.RelOpFilterBuilder +import org.partiql.planner.internal.ir.builder.RelOpIntersectBuilder import org.partiql.planner.internal.ir.builder.RelOpJoinBuilder import org.partiql.planner.internal.ir.builder.RelOpLimitBuilder import org.partiql.planner.internal.ir.builder.RelOpOffsetBuilder import org.partiql.planner.internal.ir.builder.RelOpProjectBuilder import org.partiql.planner.internal.ir.builder.RelOpScanBuilder import org.partiql.planner.internal.ir.builder.RelOpScanIndexedBuilder -import org.partiql.planner.internal.ir.builder.RelOpSetExceptBuilder -import org.partiql.planner.internal.ir.builder.RelOpSetIntersectBuilder -import org.partiql.planner.internal.ir.builder.RelOpSetUnionBuilder import org.partiql.planner.internal.ir.builder.RelOpSortBuilder import org.partiql.planner.internal.ir.builder.RelOpSortSpecBuilder +import org.partiql.planner.internal.ir.builder.RelOpUnionBuilder import org.partiql.planner.internal.ir.builder.RelOpUnpivotBuilder import org.partiql.planner.internal.ir.builder.RelTypeBuilder import org.partiql.planner.internal.ir.builder.RexBuilder @@ -768,6 +768,11 @@ internal data class Rex( } } +internal enum class SetQuantifier { + ALL, + DISTINCT, +} + internal data class Rel( @JvmField internal val type: Type, @JvmField internal val op: Op, @@ -813,7 +818,9 @@ internal data class Rel( is Distinct -> visitor.visitRelOpDistinct(this, ctx) is Filter -> visitor.visitRelOpFilter(this, ctx) is Sort -> visitor.visitRelOpSort(this, ctx) - is Set -> visitor.visitRelOpSet(this, ctx) + is Union -> visitor.visitRelOpUnion(this, ctx) + is Intersect -> visitor.visitRelOpIntersect(this, ctx) + is Except -> visitor.visitRelOpExcept(this, ctx) is Limit -> visitor.visitRelOpLimit(this, ctx) is Offset -> visitor.visitRelOpOffset(this, ctx) is Project -> visitor.visitRelOpProject(this, ctx) @@ -956,81 +963,84 @@ internal data class Rel( } } - internal sealed class Set : Op() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { - is Union -> visitor.visitRelOpSetUnion(this, ctx) - is Intersect -> visitor.visitRelOpSetIntersect(this, ctx) - is Except -> visitor.visitRelOpSetExcept(this, ctx) + internal data class Union( + @JvmField + internal val setq: SetQuantifier, + @JvmField + internal val isOuter: Boolean, + @JvmField + internal val lhs: Rel, + @JvmField + internal val rhs: Rel, + ) : Op() { + internal override val children: List by lazy { + val kids = mutableListOf() + kids.add(lhs) + kids.add(rhs) + kids.filterNotNull() } - internal enum class Quantifier { - ALL, DISTINCT, - } - internal data class Union( - @JvmField internal val quantifier: Quantifier, - @JvmField internal val lhs: Rel, - @JvmField internal val rhs: Rel, - @JvmField internal val isOuter: Boolean, - ) : Set() { - public override val children: List by lazy { - val kids = mutableListOf() - kids.add(lhs) - kids.add(rhs) - kids.filterNotNull() - } + override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpUnion(this, ctx) - override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpSetUnion(this, ctx) + internal companion object { + @JvmStatic + internal fun builder(): RelOpUnionBuilder = RelOpUnionBuilder() + } + } - internal companion object { - @JvmStatic - internal fun builder(): RelOpSetUnionBuilder = RelOpSetUnionBuilder() - } + internal data class Intersect( + @JvmField + internal val setq: SetQuantifier, + @JvmField + internal val isOuter: Boolean, + @JvmField + internal val lhs: Rel, + @JvmField + internal val rhs: Rel, + ) : Op() { + internal override val children: List by lazy { + val kids = mutableListOf() + kids.add(lhs) + kids.add(rhs) + kids.filterNotNull() } - internal data class Intersect( - @JvmField internal val quantifier: Quantifier, - @JvmField internal val lhs: Rel, - @JvmField internal val rhs: Rel, - @JvmField internal val isOuter: Boolean, - ) : Set() { - public override val children: List by lazy { - val kids = mutableListOf() - kids.add(lhs) - kids.add(rhs) - kids.filterNotNull() - } - override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpSetIntersect(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpIntersect(this, ctx) - internal companion object { - @JvmStatic - internal fun builder(): RelOpSetIntersectBuilder = RelOpSetIntersectBuilder() - } + internal companion object { + @JvmStatic + internal fun builder(): RelOpIntersectBuilder = RelOpIntersectBuilder() } + } - internal data class Except( - @JvmField internal val quantifier: Quantifier, - @JvmField internal val lhs: Rel, - @JvmField internal val rhs: Rel, - @JvmField internal val isOuter: Boolean, - ) : Set() { - public override val children: List by lazy { - val kids = mutableListOf() - kids.add(lhs) - kids.add(rhs) - kids.filterNotNull() - } + internal data class Except( + @JvmField + internal val setq: SetQuantifier, + @JvmField + internal val isOuter: Boolean, + @JvmField + internal val lhs: Rel, + @JvmField + internal val rhs: Rel, + ) : Op() { + internal override val children: List by lazy { + val kids = mutableListOf() + kids.add(lhs) + kids.add(rhs) + kids.filterNotNull() + } - override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpSetExcept(this, ctx) - internal companion object { - @JvmStatic - internal fun builder(): RelOpSetExceptBuilder = RelOpSetExceptBuilder() - } + override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpExcept(this, ctx) + + internal companion object { + @JvmStatic + internal fun builder(): RelOpExceptBuilder = RelOpExceptBuilder() } } @@ -1141,10 +1151,6 @@ internal data class Rel( FULL, PARTIAL, } - internal enum class SetQuantifier { - ALL, DISTINCT, - } - internal sealed class Call : PlanNode() { public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Unresolved -> visitor.visitRelOpAggregateCallUnresolved(this, ctx) @@ -1153,7 +1159,7 @@ internal data class Rel( internal data class Unresolved( @JvmField internal val name: String, - @JvmField internal val setQuantifier: SetQuantifier, + @JvmField internal val setq: SetQuantifier, @JvmField internal val args: List, ) : Call() { public override val children: List by lazy { @@ -1174,7 +1180,7 @@ internal data class Rel( internal data class Resolved( @JvmField internal val agg: Ref.Agg, - @JvmField internal val setQuantifier: SetQuantifier, + @JvmField internal val setq: SetQuantifier, @JvmField internal val args: List, ) : Call() { public override val children: List by lazy { diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/AstToPlan.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/AstToPlan.kt index 963ecb52d7..cd89318033 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/AstToPlan.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/AstToPlan.kt @@ -42,7 +42,7 @@ internal object AstToPlan { override fun visitStatementQuery(node: AstStatement.Query, env: Env): PlanStatement { val rex = when (val expr = node.expr) { - is Expr.SFW -> RelConverter.apply(expr, env) + is Expr.QuerySet -> RelConverter.apply(expr, env) else -> RexConverter.apply(expr, env) } return statementQuery(rex) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/NormalizeSelect.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/NormalizeSelect.kt index 6d6bc923d9..0354c39f97 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/NormalizeSelect.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/NormalizeSelect.kt @@ -18,6 +18,7 @@ import org.partiql.ast.Expr import org.partiql.ast.From import org.partiql.ast.GroupBy import org.partiql.ast.Identifier +import org.partiql.ast.QueryBody import org.partiql.ast.Select import org.partiql.ast.exprCall import org.partiql.ast.exprCase @@ -80,7 +81,7 @@ import org.partiql.value.stringValue * } FROM A AS x * ``` * - * NOTE: This does NOT transform subqueries. It operates directly on an [Expr.SFW] -- and that is it. Therefore: + * NOTE: This does NOT transform subqueries. It operates directly on an [QueryExpr.SFW] -- and that is it. Therefore: * ``` * SELECT * (SELECT 1 FROM T AS "T") @@ -97,8 +98,32 @@ import org.partiql.value.stringValue */ internal object NormalizeSelect { - internal fun normalize(node: Expr.SFW): Expr.SFW { - return Visitor.visitSFW(node, newCtx()) + internal fun normalize(node: Expr.QuerySet): Expr.QuerySet { + return when (val body = node.body) { + is QueryBody.SFW -> { + val sfw = Visitor.visitSFW(body, newCtx()) + node.copy( + body = sfw + ) + } + is QueryBody.SetOp -> { + val lhs = body.lhs.normalizeOrIdentity() + val rhs = body.rhs.normalizeOrIdentity() + node.copy( + body = body.copy( + lhs = lhs, + rhs = rhs + ) + ) + } + } + } + + private fun Expr.normalizeOrIdentity(): Expr { + return when (this) { + is Expr.QuerySet -> normalize(this) + else -> this + } } /** @@ -136,8 +161,8 @@ internal object NormalizeSelect { */ private val col = { index: Int -> "_${index + 1}" } - internal fun visitSFW(node: Expr.SFW, ctx: () -> Int): Expr.SFW { - val sfw = super.visitExprSFW(node, ctx) as Expr.SFW + internal fun visitSFW(node: QueryBody.SFW, ctx: () -> Int): QueryBody.SFW { + val sfw = super.visitQueryBodySFW(node, ctx) as QueryBody.SFW return when (val select = sfw.select) { is Select.Star -> { val selectValue = when (val group = sfw.groupBy) { @@ -150,7 +175,7 @@ internal object NormalizeSelect { } } - override fun visitExprSFW(node: Expr.SFW, ctx: () -> Int): Expr.SFW { + override fun visitQueryBodySFW(node: QueryBody.SFW, ctx: () -> Int): QueryBody.SFW { return node } 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 8a12843b89..2da241825f 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 @@ -11,6 +11,7 @@ import org.partiql.planner.internal.ir.PartiQLPlan import org.partiql.planner.internal.ir.Ref import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.Rex +import org.partiql.planner.internal.ir.SetQuantifier import org.partiql.planner.internal.ir.Statement import org.partiql.planner.internal.ir.visitor.PlanBaseVisitor import org.partiql.value.PartiQLValueExperimental @@ -325,27 +326,27 @@ internal class PlanTransform( } ) - override fun visitRelOpSetExcept(node: Rel.Op.Set.Except, ctx: Unit) = org.partiql.plan.Rel.Op.Set.Except( + override fun visitRelOpExcept(node: Rel.Op.Except, ctx: Unit) = org.partiql.plan.Rel.Op.Except( lhs = visitRel(node.lhs, ctx), rhs = visitRel(node.rhs, ctx), - quantifier = visitRelOpSetQuantifier(node.quantifier) + setq = visitSetQuantifier(node.setq) ) - override fun visitRelOpSetIntersect(node: Rel.Op.Set.Intersect, ctx: Unit) = org.partiql.plan.Rel.Op.Set.Intersect( + override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: Unit) = org.partiql.plan.Rel.Op.Intersect( lhs = visitRel(node.lhs, ctx), rhs = visitRel(node.rhs, ctx), - quantifier = visitRelOpSetQuantifier(node.quantifier) + setq = visitSetQuantifier(node.setq) ) - override fun visitRelOpSetUnion(node: Rel.Op.Set.Union, ctx: Unit) = org.partiql.plan.Rel.Op.Set.Union( + override fun visitRelOpUnion(node: Rel.Op.Union, ctx: Unit) = org.partiql.plan.Rel.Op.Union( lhs = visitRel(node.lhs, ctx), rhs = visitRel(node.rhs, ctx), - quantifier = visitRelOpSetQuantifier(node.quantifier) + setq = visitSetQuantifier(node.setq) ) - private fun visitRelOpSetQuantifier(node: Rel.Op.Set.Quantifier) = when (node) { - Rel.Op.Set.Quantifier.ALL -> org.partiql.plan.Rel.Op.Set.Quantifier.ALL - Rel.Op.Set.Quantifier.DISTINCT -> org.partiql.plan.Rel.Op.Set.Quantifier.DISTINCT + private fun visitSetQuantifier(node: SetQuantifier) = when (node) { + SetQuantifier.ALL -> org.partiql.plan.SetQuantifier.ALL + SetQuantifier.DISTINCT -> org.partiql.plan.SetQuantifier.DISTINCT } override fun visitRelOpLimit(node: Rel.Op.Limit, ctx: Unit) = org.partiql.plan.Rel.Op.Limit( @@ -395,10 +396,7 @@ internal class PlanTransform( override fun visitRelOpAggregateCallResolved(node: Rel.Op.Aggregate.Call.Resolved, ctx: Unit): PlanNode { val agg = visitRef(node.agg, ctx) val args = node.args.map { visitRex(it, ctx) } - val setQuantifier = when (node.setQuantifier) { - Rel.Op.Aggregate.SetQuantifier.ALL -> org.partiql.plan.Rel.Op.Aggregate.Call.SetQuantifier.ALL - Rel.Op.Aggregate.SetQuantifier.DISTINCT -> org.partiql.plan.Rel.Op.Aggregate.Call.SetQuantifier.DISTINCT - } + val setQuantifier = visitSetQuantifier(node.setq) return org.partiql.plan.relOpAggregateCall(agg, setQuantifier, args) } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt index f0959a3a6a..cc049a6049 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt @@ -23,6 +23,7 @@ import org.partiql.ast.From import org.partiql.ast.GroupBy import org.partiql.ast.Identifier import org.partiql.ast.OrderBy +import org.partiql.ast.QueryBody import org.partiql.ast.Select import org.partiql.ast.SetOp import org.partiql.ast.SetQuantifier @@ -87,24 +88,46 @@ internal object RelConverter { /** * Here we convert an SFW to composed [Rel]s, then apply the appropriate relation-value projection to get a [Rex]. */ - internal fun apply(sfw: Expr.SFW, env: Env): Rex { - val normalizedSfw = NormalizeSelect.normalize(sfw) - val rel = normalizedSfw.accept(ToRel(env), nil) - val rex = when (val projection = normalizedSfw.select) { - // PIVOT ... FROM - is Select.Pivot -> { - val key = projection.key.toRex(env) - val value = projection.value.toRex(env) - val type = (STRUCT) - val op = rexOpPivot(key, value, rel) - rex(type, op) - } - // SELECT VALUE ... FROM - is Select.Value -> { - assert(rel.type.schema.size == 1) { - "Expected SELECT VALUE's input to have a single binding. " + - "However, it contained: ${rel.type.schema.map { it.name }}." + internal fun apply(qSet: Expr.QuerySet, env: Env): Rex { + val newQSet = NormalizeSelect.normalize(qSet) + val rex = when (val body = newQSet.body) { + is QueryBody.SFW -> { + val rel = newQSet.accept(ToRel(env), nil) + when (val projection = body.select) { + // PIVOT ... FROM + is Select.Pivot -> { + val key = projection.key.toRex(env) + val value = projection.value.toRex(env) + val type = (STRUCT) + val op = rexOpPivot(key, value, rel) + rex(type, op) + } + // SELECT VALUE ... FROM + is Select.Value -> { + assert(rel.type.schema.size == 1) { + "Expected SELECT VALUE's input to have a single binding. " + + "However, it contained: ${rel.type.schema.map { it.name }}." + } + val constructor = rex(ANY, rexOpVarLocal(0, 0)) + val op = rexOpSelect(constructor, rel) + val type = when (rel.type.props.contains(Rel.Prop.ORDERED)) { + true -> (LIST) + else -> (BAG) + } + rex(type, op) + } + // SELECT * FROM + is Select.Star -> { + throw IllegalArgumentException("AST not normalized") + } + // SELECT ... FROM + is Select.Project -> { + throw IllegalArgumentException("AST not normalized") + } } + } + is QueryBody.SetOp -> { + val rel = newQSet.accept(ToRel(env), nil) val constructor = rex(ANY, rexOpVarLocal(0, 0)) val op = rexOpSelect(constructor, rel) val type = when (rel.type.props.contains(Rel.Prop.ORDERED)) { @@ -113,14 +136,6 @@ internal object RelConverter { } rex(type, op) } - // SELECT * FROM - is Select.Star -> { - throw IllegalArgumentException("AST not normalized") - } - // SELECT ... FROM - is Select.Project -> { - throw IllegalArgumentException("AST not normalized") - } } return rex } @@ -140,34 +155,49 @@ internal object RelConverter { * Translate SFW AST node to a pipeline of [Rel] operators; skip any SELECT VALUE or PIVOT projection. */ - override fun visitExprSFW(node: Expr.SFW, input: Rel): Rel { - var sel = node - var rel = visitFrom(sel.from, nil) - rel = convertWhere(rel, sel.where) - // kotlin does not have destructuring reassignment - val (_sel, _rel) = convertAgg(rel, sel, sel.groupBy) - sel = _sel - rel = _rel - // Plan.create (possibly rewritten) sel node - rel = convertHaving(rel, sel.having) - rel = convertSetOp(rel, sel.setOp) - rel = convertOrderBy(rel, sel.orderBy) - // offset should precede limit - rel = convertOffset(rel, sel.offset) - rel = convertLimit(rel, sel.limit) - rel = convertExclude(rel, sel.exclude) - // append SQL projection if present - rel = when (val projection = sel.select) { - is Select.Value -> { - val project = visitSelectValue(projection, rel) - visitSetQuantifier(projection.setq, project) + override fun visitExprQuerySet(node: Expr.QuerySet, ctx: Rel): Rel { + val body = node.body + val orderBy = node.orderBy + val limit = node.limit + val offset = node.offset + when (body) { + is QueryBody.SFW -> { + var sel = body + var rel = visitFrom(sel.from, nil) + rel = convertWhere(rel, sel.where) + // kotlin does not have destructuring reassignment + val (_sel, _rel) = convertAgg(rel, sel, sel.groupBy) + sel = _sel + rel = _rel + // Plan.create (possibly rewritten) sel node + rel = convertHaving(rel, sel.having) + rel = convertOrderBy(rel, orderBy) + // offset should precede limit + rel = convertOffset(rel, offset) + rel = convertLimit(rel, limit) + rel = convertExclude(rel, sel.exclude) + // append SQL projection if present + rel = when (val projection = sel.select) { + is Select.Value -> { + val project = visitSelectValue(projection, rel) + visitSetQuantifier(projection.setq, project) + } + is Select.Star, is Select.Project -> { + error("AST not normalized, found ${projection.javaClass.simpleName}") + } + is Select.Pivot -> rel // Skip PIVOT + } + return rel } - is Select.Star, is Select.Project -> { - error("AST not normalized, found ${projection.javaClass.simpleName}") + is QueryBody.SetOp -> { + var rel = convertSetOp(body) + rel = convertOrderBy(rel, orderBy) + // offset should precede limit + rel = convertOffset(rel, offset) + rel = convertLimit(rel, limit) + return rel } - is Select.Pivot -> rel // Skip PIVOT } - return rel } /** @@ -342,7 +372,7 @@ internal object RelConverter { * 2. Rel which has the appropriate Rex.Agg calls and groups */ @OptIn(PartiQLValueExperimental::class) - private fun convertAgg(input: Rel, select: Expr.SFW, groupBy: GroupBy?): Pair { + private fun convertAgg(input: Rel, select: QueryBody.SFW, groupBy: GroupBy?): Pair { // Rewrite and extract all aggregations in the SELECT clause val (sel, aggregations) = AggregationTransform.apply(select) @@ -373,14 +403,14 @@ internal object RelConverter { if (name == "count" && expr.args.isEmpty()) { relOpAggregateCallUnresolved( name, - Rel.Op.Aggregate.SetQuantifier.ALL, + org.partiql.planner.internal.ir.SetQuantifier.ALL, args = listOf(exprLit(int32Value(1)).toRex(env)) ) } else { val setq = when (expr.setq) { - null -> Rel.Op.Aggregate.SetQuantifier.ALL - SetQuantifier.ALL -> Rel.Op.Aggregate.SetQuantifier.ALL - SetQuantifier.DISTINCT -> Rel.Op.Aggregate.SetQuantifier.DISTINCT + null -> org.partiql.planner.internal.ir.SetQuantifier.ALL + SetQuantifier.ALL -> org.partiql.planner.internal.ir.SetQuantifier.ALL + SetQuantifier.DISTINCT -> org.partiql.planner.internal.ir.SetQuantifier.DISTINCT } relOpAggregateCallUnresolved(name, setq, args) } @@ -398,7 +428,7 @@ internal object RelConverter { ) } val arg = listOf(rex(ANY, rexOpStruct(fields))) - calls.add(relOpAggregateCallUnresolved("group_as", Rel.Op.Aggregate.SetQuantifier.ALL, arg)) + calls.add(relOpAggregateCallUnresolved("group_as", org.partiql.planner.internal.ir.SetQuantifier.ALL, arg)) } } var groups = emptyList() @@ -441,24 +471,34 @@ internal object RelConverter { return rel(type, op) } + private fun visitIfQuerySet(expr: Expr): Rel { + return when (expr) { + is Expr.QuerySet -> visit(expr, nil) + else -> { + val rex = RexConverter.applyRel(expr, env) + val op = relOpScan(rex) + val type = Rel.Type(listOf(Rel.Binding("_1", ANY)), props = emptySet()) + return rel(type, op) + } + } + } + /** * Append SQL set operator if present */ - private fun convertSetOp(input: Rel, setOp: Expr.SFW.SetOp?): Rel { - if (setOp == null) { - return input - } - val type = input.type.copy(props = emptySet()) - val lhs = input - val rhs = visitExprSFW(setOp.operand, nil) - val quantifier = when (setOp.type.setq) { - SetQuantifier.ALL -> Rel.Op.Set.Quantifier.ALL - null, SetQuantifier.DISTINCT -> Rel.Op.Set.Quantifier.DISTINCT + private fun convertSetOp(setExpr: QueryBody.SetOp): Rel { + val lhs = visitIfQuerySet(setExpr.lhs) + val rhs = visitIfQuerySet(setExpr.rhs) + val type = Rel.Type(listOf(Rel.Binding("_0", ANY)), props = emptySet()) + val quantifier = when (setExpr.type.setq) { + SetQuantifier.ALL -> org.partiql.planner.internal.ir.SetQuantifier.ALL + null, SetQuantifier.DISTINCT -> org.partiql.planner.internal.ir.SetQuantifier.DISTINCT } - val op = when (setOp.type.type) { - SetOp.Type.UNION -> Rel.Op.Set.Union(quantifier, lhs, rhs, false) - SetOp.Type.EXCEPT -> Rel.Op.Set.Except(quantifier, lhs, rhs, false) - SetOp.Type.INTERSECT -> Rel.Op.Set.Intersect(quantifier, lhs, rhs, false) + val outer = setExpr.isOuter + val op = when (setExpr.type.type) { + SetOp.Type.UNION -> Rel.Op.Union(quantifier, outer, lhs, rhs) + SetOp.Type.EXCEPT -> Rel.Op.Except(quantifier, outer, lhs, rhs) + SetOp.Type.INTERSECT -> Rel.Op.Intersect(quantifier, outer, lhs, rhs) } return rel(type, op) } @@ -602,11 +642,11 @@ internal object RelConverter { val keys: List ) - fun apply(node: Expr.SFW): Pair> { + fun apply(node: QueryBody.SFW): Pair> { val aggs = mutableListOf() val keys = node.groupBy?.keys ?: emptyList() val context = Context(aggs, keys) - val select = super.visitExprSFW(node, context) as Expr.SFW + val select = super.visitQueryBodySFW(node, context) as QueryBody.SFW return Pair(select, aggs) } @@ -619,7 +659,7 @@ internal object RelConverter { } // only rewrite top-level SFW - override fun visitExprSFW(node: Expr.SFW, ctx: Context): AstNode = node + override fun visitQueryBodySFW(node: QueryBody.SFW, ctx: Context): AstNode = node override fun visitExprCall(node: Expr.Call, ctx: Context) = ast { // TODO replace w/ proper function resolution to determine whether a function call is a scalar or aggregate. diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt index e2cb7522ee..b478205610 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt @@ -19,8 +19,8 @@ package org.partiql.planner.internal.transforms import org.partiql.ast.AstNode import org.partiql.ast.DatetimeField import org.partiql.ast.Expr +import org.partiql.ast.QueryBody import org.partiql.ast.Select -import org.partiql.ast.SetOp import org.partiql.ast.SetQuantifier import org.partiql.ast.Type import org.partiql.ast.visitor.AstBaseVisitor @@ -284,10 +284,14 @@ internal object RexConverter { private fun isLiteralArray(node: Expr): Boolean = node is Expr.Collection && (node.type == Expr.Collection.Type.ARRAY || node.type == Expr.Collection.Type.LIST) - private fun isSqlSelect(node: Expr): Boolean = node is Expr.SFW && - ( - node.select is Select.Project || node.select is Select.Star - ) + private fun isSqlSelect(node: Expr): Boolean { + return if (node is Expr.QuerySet) { + val body = node.body + body is QueryBody.SFW && (body.select is Select.Project || body.select is Select.Star) + } else { + false + } + } override fun visitExprPath(node: Expr.Path, context: Env): Rex { // Args @@ -947,42 +951,7 @@ internal object RexConverter { return rex(type, call) } - override fun visitExprSFW(node: Expr.SFW, context: Env): Rex = RelConverter.apply(node, context) - - override fun visitExprBagOp(node: Expr.BagOp, ctx: Env): Rex { - val lhs = Rel( - type = Rel.Type(listOf(Rel.Binding("_0", ANY)), props = emptySet()), - op = Rel.Op.Scan(visitExpr(node.lhs, ctx)) - ) - val rhs = Rel( - type = Rel.Type(listOf(Rel.Binding("_1", ANY)), props = emptySet()), - op = Rel.Op.Scan(visitExpr(node.rhs, ctx)) - ) - val quantifier = when (node.type.setq) { - SetQuantifier.ALL -> Rel.Op.Set.Quantifier.ALL - null, SetQuantifier.DISTINCT -> Rel.Op.Set.Quantifier.DISTINCT - } - val isOuter = node.outer == true - val op = when (node.type.type) { - SetOp.Type.UNION -> Rel.Op.Set.Union(quantifier, lhs, rhs, isOuter) - SetOp.Type.EXCEPT -> Rel.Op.Set.Except(quantifier, lhs, rhs, isOuter) - SetOp.Type.INTERSECT -> Rel.Op.Set.Intersect(quantifier, lhs, rhs, isOuter) - } - val rel = Rel( - type = Rel.Type(listOf(Rel.Binding("_0", ANY)), props = emptySet()), - op = op - ) - return Rex( - type = ANY, - op = Rex.Op.Select( - constructor = Rex( - ANY, - Rex.Op.Var.Unresolved(Identifier.delimited("_0"), Rex.Op.Var.Scope.LOCAL) - ), - rel = rel - ) - ) - } + override fun visitExprQuerySet(node: Expr.QuerySet, context: Env): Rex = RelConverter.apply(node, context) // Helpers diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt index 3463001107..cf27536cb8 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt @@ -271,11 +271,11 @@ internal class PlanTyper(private val env: Env) { return rel(type, op) } - override fun visitRelOpSetExcept(node: Rel.Op.Set.Except, ctx: Rel.Type?): Rel { + override fun visitRelOpExcept(node: Rel.Op.Except, ctx: Rel.Type?): Rel { val lhs = visitRel(node.lhs, node.lhs.type) val rhs = visitRel(node.rhs, node.rhs.type) // Check for Compatibility - if (!setOpSchemaSizesMatch(lhs, rhs)) { + if (!node.isOuter && !setOpSchemaSizesMatch(lhs, rhs)) { return createRelErrForSetOpMismatchSizes() } if (!node.isOuter && !setOpSchemaTypesMatch(lhs, rhs)) { @@ -286,11 +286,11 @@ internal class PlanTyper(private val env: Env) { return Rel(type, node.copy(lhs = lhs, rhs = rhs)) } - override fun visitRelOpSetIntersect(node: Rel.Op.Set.Intersect, ctx: Rel.Type?): Rel { + override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: Rel.Type?): Rel { val lhs = visitRel(node.lhs, node.lhs.type) val rhs = visitRel(node.rhs, node.rhs.type) // Check for Compatibility - if (!setOpSchemaSizesMatch(lhs, rhs)) { + if (!node.isOuter && !setOpSchemaSizesMatch(lhs, rhs)) { return createRelErrForSetOpMismatchSizes() } if (!node.isOuter && !setOpSchemaTypesMatch(lhs, rhs)) { @@ -301,11 +301,11 @@ internal class PlanTyper(private val env: Env) { return Rel(type, node.copy(lhs = lhs, rhs = rhs)) } - override fun visitRelOpSetUnion(node: Rel.Op.Set.Union, ctx: Rel.Type?): Rel { + override fun visitRelOpUnion(node: Rel.Op.Union, ctx: Rel.Type?): Rel { val lhs = visitRel(node.lhs, node.lhs.type) val rhs = visitRel(node.rhs, node.rhs.type) // Check for Compatibility - if (!setOpSchemaSizesMatch(lhs, rhs)) { + if (!node.isOuter && !setOpSchemaSizesMatch(lhs, rhs)) { return createRelErrForSetOpMismatchSizes() } if (!node.isOuter && !setOpSchemaTypesMatch(lhs, rhs)) { @@ -1246,10 +1246,10 @@ internal class PlanTyper(private val env: Env) { fun resolveAgg(node: Rel.Op.Aggregate.Call.Unresolved): Pair { // Type the arguments val args = node.args.map { visitRex(it, null) } - val argsResolved = Rel.Op.Aggregate.Call.Unresolved(node.name, node.setQuantifier, args) + val argsResolved = Rel.Op.Aggregate.Call.Unresolved(node.name, node.setq, args) // Resolve the function - val call = env.resolveAgg(node.name, node.setQuantifier, args) ?: return argsResolved to CompilerType(PType.dynamic()) + val call = env.resolveAgg(node.name, node.setq, args) ?: return argsResolved to CompilerType(PType.dynamic()) return call to CompilerType(call.agg.signature.returns) } } diff --git a/partiql-planner/src/main/resources/partiql_plan_internal.ion b/partiql-planner/src/main/resources/partiql_plan_internal.ion index e4bc767c83..b210934d39 100644 --- a/partiql-planner/src/main/resources/partiql_plan_internal.ion +++ b/partiql-planner/src/main/resources/partiql_plan_internal.ion @@ -58,6 +58,12 @@ statement::[ }, ] +// [ ALL | DISTINCT ] +set_quantifier::[ + ALL, + DISTINCT, +] + // Rex rex::{ type: static_type, @@ -278,38 +284,32 @@ rel::{ ], }, - // In each variant, is_outer is an internal-only field. It is specifically used to aid in typing the plan and throwing potential errors. // For example, if a user were to write: `<< { 'a': 1 } >>` UNION << { 'b': 'hello' } >>, then this would FAIL // due to [RFC-0007](https://github.com/partiql/partiql-lang/blob/main/RFCs/0007-rfc-bag-operators.md). However, // if a user were to use OUTER UNION, then it would work. Under the hood at execution, the operator is the same -- // however, at planning time, with static type analysis, we can fail queries prior to their execution. - set::[ - union::{ - quantifier: quantifier, - lhs: rel, - rhs: rel, - is_outer: bool - }, - - intersect::{ - quantifier: quantifier, - lhs: rel, - rhs: rel, - is_outer: bool - }, + // SQL set ops + union::{ + setq: set_quantifier, + is_outer: bool, + lhs: rel, + rhs: rel, + }, - except::{ - quantifier: quantifier, - lhs: rel, - rhs: rel, - is_outer: bool - }, + intersect::{ + setq: set_quantifier, + is_outer: bool, + lhs: rel, + rhs: rel, + }, - _::[ - quantifier::[ ALL, DISTINCT ], - ] - ], + except::{ + setq: set_quantifier, + is_outer: bool, + lhs: rel, + rhs: rel, + }, limit::{ input: rel, @@ -347,16 +347,15 @@ rel::{ call::[ unresolved::{ name: string, - set_quantifier: set_quantifier, + setq: set_quantifier, args: list::[rex], }, resolved::{ agg: '.ref.agg', - set_quantifier: set_quantifier, + setq: set_quantifier, args: list::[rex], }, ], - set_quantifier::[ ALL, DISTINCT ] ], }, diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/transforms/NormalizeSelectTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/transforms/NormalizeSelectTest.kt index fb42234794..0ca74b17c7 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/transforms/NormalizeSelectTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/transforms/NormalizeSelectTest.kt @@ -128,39 +128,43 @@ class NormalizeSelectTest { ) private fun select(vararg items: Select.Project.Item) = ast { - exprSFW { - select = selectProject { - this.items += items - } - from = fromValue { - expr = variable("T") - type = From.Value.Type.SCAN + exprQuerySet { + body = queryBodySFW { + select = selectProject { + this.items += items + } + from = fromValue { + expr = variable("T") + type = From.Value.Type.SCAN + } } } } @OptIn(PartiQLValueExperimental::class) private fun selectValue(vararg items: Pair) = ast { - exprSFW { - select = selectValue { - constructor = exprStruct { - for ((k, v) in items) { - fields += exprStructField { - name = exprLit(stringValue(k)) - value = v + exprQuerySet { + body = queryBodySFW { + select = selectValue { + constructor = exprStruct { + for ((k, v) in items) { + fields += exprStructField { + name = exprLit(stringValue(k)) + value = v + } } } } - } - from = fromValue { - expr = exprVar { - identifier = identifierSymbol { - symbol = "T" - caseSensitivity = Identifier.CaseSensitivity.INSENSITIVE + from = fromValue { + expr = exprVar { + identifier = identifierSymbol { + symbol = "T" + caseSensitivity = Identifier.CaseSensitivity.INSENSITIVE + } + scope = Expr.Var.Scope.DEFAULT } - scope = Expr.Var.Scope.DEFAULT + type = From.Value.Type.SCAN } - type = From.Value.Type.SCAN } } } diff --git a/test/partiql-tests b/test/partiql-tests index 26ab08ec49..87809f907f 160000 --- a/test/partiql-tests +++ b/test/partiql-tests @@ -1 +1 @@ -Subproject commit 26ab08ec49b889550ecca4878e2a338a712dcf35 +Subproject commit 87809f907f8232866562ad6b0eb1e01123d8bf09