diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index 688c53ecf..ce7f25c0e 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -14,9 +14,9 @@ public final class org/partiql/ast/Ast { public static final fun excludeStepCollWildcard ()Lorg/partiql/ast/Exclude$Step$CollWildcard; 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 exprBinary (Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Binary; 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; public static final fun exprCanLosslessCast (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Type;)Lorg/partiql/ast/Expr$CanLosslessCast; @@ -34,7 +34,10 @@ public final class org/partiql/ast/Ast { public static final fun exprLike (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Ljava/lang/Boolean;)Lorg/partiql/ast/Expr$Like; public static final fun exprLit (Lorg/partiql/value/PartiQLValue;)Lorg/partiql/ast/Expr$Lit; public static final fun exprMatch (Lorg/partiql/ast/Expr;Lorg/partiql/ast/GraphMatch;)Lorg/partiql/ast/Expr$Match; + public static final fun exprNot (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Not; public static final fun exprNullIf (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$NullIf; + public static final fun exprOperator (Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Operator; + public static final fun exprOr (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Or; public static final fun exprOverlay (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Overlay; public static final fun exprParameter (I)Lorg/partiql/ast/Expr$Parameter; public static final fun exprPath (Lorg/partiql/ast/Expr;Ljava/util/List;)Lorg/partiql/ast/Expr$Path; @@ -50,7 +53,6 @@ public final class org/partiql/ast/Ast { public static final fun exprStructField (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Struct$Field; public static final fun exprSubstring (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Substring; public static final fun exprTrim (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$Trim$Spec;)Lorg/partiql/ast/Expr$Trim; - public static final fun exprUnary (Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Unary; public static final fun exprValues (Ljava/util/List;)Lorg/partiql/ast/Expr$Values; public static final fun exprValuesRow (Ljava/util/List;)Lorg/partiql/ast/Expr$Values$Row; public static final fun exprVar (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/Expr$Var$Scope;)Lorg/partiql/ast/Expr$Var; @@ -515,6 +517,27 @@ public abstract class org/partiql/ast/Expr : org/partiql/ast/AstNode { public fun accept (Lorg/partiql/ast/visitor/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; } +public final class org/partiql/ast/Expr$And : org/partiql/ast/Expr { + public static final field Companion Lorg/partiql/ast/Expr$And$Companion; + public final field lhs Lorg/partiql/ast/Expr; + public final field rhs Lorg/partiql/ast/Expr; + public fun (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/ExprAndBuilder; + public final fun component1 ()Lorg/partiql/ast/Expr; + public final fun component2 ()Lorg/partiql/ast/Expr; + public final fun copy (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$And; + public static synthetic fun copy$default (Lorg/partiql/ast/Expr$And;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$And; + 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$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; @@ -565,49 +588,6 @@ public final class org/partiql/ast/Expr$Between$Companion { public final fun builder ()Lorg/partiql/ast/builder/ExprBetweenBuilder; } -public final class org/partiql/ast/Expr$Binary : org/partiql/ast/Expr { - public static final field Companion Lorg/partiql/ast/Expr$Binary$Companion; - public final field lhs Lorg/partiql/ast/Expr; - public final field op Lorg/partiql/ast/Expr$Binary$Op; - public final field rhs Lorg/partiql/ast/Expr; - public fun (Lorg/partiql/ast/Expr$Binary$Op;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/ExprBinaryBuilder; - public final fun component1 ()Lorg/partiql/ast/Expr$Binary$Op; - public final fun component2 ()Lorg/partiql/ast/Expr; - public final fun component3 ()Lorg/partiql/ast/Expr; - public final fun copy (Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Binary; - public static synthetic fun copy$default (Lorg/partiql/ast/Expr$Binary;Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Binary; - 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$Binary$Companion { - public final fun builder ()Lorg/partiql/ast/builder/ExprBinaryBuilder; -} - -public final class org/partiql/ast/Expr$Binary$Op : java/lang/Enum { - public static final field AND Lorg/partiql/ast/Expr$Binary$Op; - public static final field BITWISE_AND Lorg/partiql/ast/Expr$Binary$Op; - public static final field CONCAT Lorg/partiql/ast/Expr$Binary$Op; - public static final field DIVIDE Lorg/partiql/ast/Expr$Binary$Op; - public static final field EQ Lorg/partiql/ast/Expr$Binary$Op; - public static final field GT Lorg/partiql/ast/Expr$Binary$Op; - public static final field GTE Lorg/partiql/ast/Expr$Binary$Op; - public static final field LT Lorg/partiql/ast/Expr$Binary$Op; - public static final field LTE Lorg/partiql/ast/Expr$Binary$Op; - public static final field MINUS Lorg/partiql/ast/Expr$Binary$Op; - public static final field MODULO Lorg/partiql/ast/Expr$Binary$Op; - public static final field NE Lorg/partiql/ast/Expr$Binary$Op; - public static final field OR Lorg/partiql/ast/Expr$Binary$Op; - public static final field PLUS Lorg/partiql/ast/Expr$Binary$Op; - public static final field TIMES Lorg/partiql/ast/Expr$Binary$Op; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/Expr$Binary$Op; - public static fun values ()[Lorg/partiql/ast/Expr$Binary$Op; -} - public final class org/partiql/ast/Expr$Call : org/partiql/ast/Expr { public static final field Companion Lorg/partiql/ast/Expr$Call$Companion; public final field args Ljava/util/List; @@ -985,6 +965,25 @@ public final class org/partiql/ast/Expr$Match$Companion { public final fun builder ()Lorg/partiql/ast/builder/ExprMatchBuilder; } +public final class org/partiql/ast/Expr$Not : org/partiql/ast/Expr { + public static final field Companion Lorg/partiql/ast/Expr$Not$Companion; + public final field value Lorg/partiql/ast/Expr; + public fun (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/ExprNotBuilder; + public final fun component1 ()Lorg/partiql/ast/Expr; + public final fun copy (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Not; + public static synthetic fun copy$default (Lorg/partiql/ast/Expr$Not;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Not; + 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$Not$Companion { + public final fun builder ()Lorg/partiql/ast/builder/ExprNotBuilder; +} + public final class org/partiql/ast/Expr$NullIf : org/partiql/ast/Expr { public static final field Companion Lorg/partiql/ast/Expr$NullIf$Companion; public final field nullifier Lorg/partiql/ast/Expr; @@ -1006,6 +1005,50 @@ public final class org/partiql/ast/Expr$NullIf$Companion { public final fun builder ()Lorg/partiql/ast/builder/ExprNullIfBuilder; } +public final class org/partiql/ast/Expr$Operator : org/partiql/ast/Expr { + public static final field Companion Lorg/partiql/ast/Expr$Operator$Companion; + public final field lhs Lorg/partiql/ast/Expr; + public final field rhs Lorg/partiql/ast/Expr; + public final field symbol Ljava/lang/String; + public fun (Ljava/lang/String;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/ExprOperatorBuilder; + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Lorg/partiql/ast/Expr; + public final fun component3 ()Lorg/partiql/ast/Expr; + public final fun copy (Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Operator; + public static synthetic fun copy$default (Lorg/partiql/ast/Expr$Operator;Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Operator; + 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$Operator$Companion { + public final fun builder ()Lorg/partiql/ast/builder/ExprOperatorBuilder; +} + +public final class org/partiql/ast/Expr$Or : org/partiql/ast/Expr { + public static final field Companion Lorg/partiql/ast/Expr$Or$Companion; + public final field lhs Lorg/partiql/ast/Expr; + public final field rhs Lorg/partiql/ast/Expr; + public fun (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/ExprOrBuilder; + public final fun component1 ()Lorg/partiql/ast/Expr; + public final fun component2 ()Lorg/partiql/ast/Expr; + public final fun copy (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Or; + public static synthetic fun copy$default (Lorg/partiql/ast/Expr$Or;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Or; + 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$Or$Companion { + public final fun builder ()Lorg/partiql/ast/builder/ExprOrBuilder; +} + public final class org/partiql/ast/Expr$Overlay : org/partiql/ast/Expr { public static final field Companion Lorg/partiql/ast/Expr$Overlay$Companion; public final field length Lorg/partiql/ast/Expr; @@ -1356,35 +1399,6 @@ public final class org/partiql/ast/Expr$Trim$Spec : java/lang/Enum { public static fun values ()[Lorg/partiql/ast/Expr$Trim$Spec; } -public final class org/partiql/ast/Expr$Unary : org/partiql/ast/Expr { - public static final field Companion Lorg/partiql/ast/Expr$Unary$Companion; - public final field expr Lorg/partiql/ast/Expr; - public final field op Lorg/partiql/ast/Expr$Unary$Op; - public fun (Lorg/partiql/ast/Expr$Unary$Op;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/ExprUnaryBuilder; - public final fun component1 ()Lorg/partiql/ast/Expr$Unary$Op; - public final fun component2 ()Lorg/partiql/ast/Expr; - public final fun copy (Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;)Lorg/partiql/ast/Expr$Unary; - public static synthetic fun copy$default (Lorg/partiql/ast/Expr$Unary;Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Unary; - 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$Unary$Companion { - public final fun builder ()Lorg/partiql/ast/builder/ExprUnaryBuilder; -} - -public final class org/partiql/ast/Expr$Unary$Op : java/lang/Enum { - public static final field NEG Lorg/partiql/ast/Expr$Unary$Op; - public static final field NOT Lorg/partiql/ast/Expr$Unary$Op; - public static final field POS Lorg/partiql/ast/Expr$Unary$Op; - public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/Expr$Unary$Op; - public static fun values ()[Lorg/partiql/ast/Expr$Unary$Op; -} - public final class org/partiql/ast/Expr$Values : org/partiql/ast/Expr { public static final field Companion Lorg/partiql/ast/Expr$Values$Companion; public final field rows Ljava/util/List; @@ -4006,12 +4020,12 @@ public final class org/partiql/ast/builder/AstBuilder { public static synthetic fun excludeStepStructField$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Identifier$Symbol;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Exclude$Step$StructField; public final fun excludeStepStructWildcard (Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Exclude$Step$StructWildcard; 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 exprBinary (Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Binary; - public static synthetic fun exprBinary$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Binary; public final fun exprCall (Lorg/partiql/ast/Identifier;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Call; public static synthetic fun exprCall$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Identifier;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Call; public final fun exprCanCast (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Type;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$CanCast; @@ -4046,8 +4060,14 @@ public final class org/partiql/ast/builder/AstBuilder { public static synthetic fun exprLit$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/value/PartiQLValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Lit; public final fun exprMatch (Lorg/partiql/ast/Expr;Lorg/partiql/ast/GraphMatch;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Match; public static synthetic fun exprMatch$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/GraphMatch;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Match; + public final fun exprNot (Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Not; + public static synthetic fun exprNot$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Not; public final fun exprNullIf (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$NullIf; public static synthetic fun exprNullIf$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$NullIf; + public final fun exprOperator (Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Operator; + public static synthetic fun exprOperator$default (Lorg/partiql/ast/builder/AstBuilder;Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Operator; + public final fun exprOr (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Or; + public static synthetic fun exprOr$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$Or; public final fun exprOverlay (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Overlay; public static synthetic fun exprOverlay$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Overlay; public final fun exprParameter (Ljava/lang/Integer;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Parameter; @@ -4078,8 +4098,6 @@ public final class org/partiql/ast/builder/AstBuilder { public static synthetic fun exprSubstring$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Substring; public final fun exprTrim (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$Trim$Spec;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Trim; public static synthetic fun exprTrim$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr$Trim$Spec;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Trim; - public final fun exprUnary (Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Unary; - public static synthetic fun exprUnary$default (Lorg/partiql/ast/builder/AstBuilder;Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Unary; public final fun exprValues (Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Values; public static synthetic fun exprValues$default (Lorg/partiql/ast/builder/AstBuilder;Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/partiql/ast/Expr$Values; public final fun exprValuesRow (Ljava/util/List;Lkotlin/jvm/functions/Function1;)Lorg/partiql/ast/Expr$Values$Row; @@ -4473,6 +4491,19 @@ public final class org/partiql/ast/builder/ExcludeStepStructWildcardBuilder { public final fun build ()Lorg/partiql/ast/Exclude$Step$StructWildcard; } +public final class org/partiql/ast/builder/ExprAndBuilder { + public fun ()V + public fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public synthetic fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/ast/Expr$And; + public final fun getLhs ()Lorg/partiql/ast/Expr; + public final fun getRhs ()Lorg/partiql/ast/Expr; + public final fun lhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprAndBuilder; + public final fun rhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprAndBuilder; + public final fun setLhs (Lorg/partiql/ast/Expr;)V + 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 @@ -4511,22 +4542,6 @@ public final class org/partiql/ast/builder/ExprBetweenBuilder { public final fun value (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprBetweenBuilder; } -public final class org/partiql/ast/builder/ExprBinaryBuilder { - public fun ()V - public fun (Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V - public synthetic fun (Lorg/partiql/ast/Expr$Binary$Op;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/ast/Expr$Binary; - public final fun getLhs ()Lorg/partiql/ast/Expr; - public final fun getOp ()Lorg/partiql/ast/Expr$Binary$Op; - public final fun getRhs ()Lorg/partiql/ast/Expr; - public final fun lhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprBinaryBuilder; - public final fun op (Lorg/partiql/ast/Expr$Binary$Op;)Lorg/partiql/ast/builder/ExprBinaryBuilder; - public final fun rhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprBinaryBuilder; - public final fun setLhs (Lorg/partiql/ast/Expr;)V - public final fun setOp (Lorg/partiql/ast/Expr$Binary$Op;)V - public final fun setRhs (Lorg/partiql/ast/Expr;)V -} - public final class org/partiql/ast/builder/ExprCallBuilder { public fun ()V public fun (Lorg/partiql/ast/Identifier;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;)V @@ -4763,6 +4778,16 @@ public final class org/partiql/ast/builder/ExprMatchBuilder { public final fun setPattern (Lorg/partiql/ast/GraphMatch;)V } +public final class org/partiql/ast/builder/ExprNotBuilder { + public fun ()V + public fun (Lorg/partiql/ast/Expr;)V + public synthetic fun (Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/ast/Expr$Not; + public final fun getValue ()Lorg/partiql/ast/Expr; + public final fun setValue (Lorg/partiql/ast/Expr;)V + public final fun value (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprNotBuilder; +} + public final class org/partiql/ast/builder/ExprNullIfBuilder { public fun ()V public fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V @@ -4776,6 +4801,35 @@ public final class org/partiql/ast/builder/ExprNullIfBuilder { public final fun value (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprNullIfBuilder; } +public final class org/partiql/ast/builder/ExprOperatorBuilder { + public fun ()V + public fun (Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public synthetic fun (Ljava/lang/String;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/ast/Expr$Operator; + public final fun getLhs ()Lorg/partiql/ast/Expr; + public final fun getRhs ()Lorg/partiql/ast/Expr; + public final fun getSymbol ()Ljava/lang/String; + public final fun lhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprOperatorBuilder; + public final fun rhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprOperatorBuilder; + public final fun setLhs (Lorg/partiql/ast/Expr;)V + public final fun setRhs (Lorg/partiql/ast/Expr;)V + public final fun setSymbol (Ljava/lang/String;)V + public final fun symbol (Ljava/lang/String;)Lorg/partiql/ast/builder/ExprOperatorBuilder; +} + +public final class org/partiql/ast/builder/ExprOrBuilder { + public fun ()V + public fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V + public synthetic fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun build ()Lorg/partiql/ast/Expr$Or; + public final fun getLhs ()Lorg/partiql/ast/Expr; + public final fun getRhs ()Lorg/partiql/ast/Expr; + public final fun lhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprOrBuilder; + public final fun rhs (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprOrBuilder; + public final fun setLhs (Lorg/partiql/ast/Expr;)V + public final fun setRhs (Lorg/partiql/ast/Expr;)V +} + public final class org/partiql/ast/builder/ExprOverlayBuilder { public fun ()V public fun (Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;Lorg/partiql/ast/Expr;)V @@ -4979,19 +5033,6 @@ public final class org/partiql/ast/builder/ExprTrimBuilder { public final fun value (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprTrimBuilder; } -public final class org/partiql/ast/builder/ExprUnaryBuilder { - public fun ()V - public fun (Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;)V - public synthetic fun (Lorg/partiql/ast/Expr$Unary$Op;Lorg/partiql/ast/Expr;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun build ()Lorg/partiql/ast/Expr$Unary; - public final fun expr (Lorg/partiql/ast/Expr;)Lorg/partiql/ast/builder/ExprUnaryBuilder; - public final fun getExpr ()Lorg/partiql/ast/Expr; - public final fun getOp ()Lorg/partiql/ast/Expr$Unary$Op; - public final fun op (Lorg/partiql/ast/Expr$Unary$Op;)Lorg/partiql/ast/builder/ExprUnaryBuilder; - public final fun setExpr (Lorg/partiql/ast/Expr;)V - public final fun setOp (Lorg/partiql/ast/Expr$Unary$Op;)V -} - public final class org/partiql/ast/builder/ExprValuesBuilder { public fun ()V public fun (Ljava/util/List;)V @@ -6369,12 +6410,12 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/visitor/A public fun visitExcludeStepStructField (Lorg/partiql/ast/Exclude$Step$StructField;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExcludeStepStructWildcard (Lorg/partiql/ast/Exclude$Step$StructWildcard;Ljava/lang/Object;)Ljava/lang/Object; 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 visitExprBinary (Lorg/partiql/ast/Expr$Binary;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprBinary (Lorg/partiql/ast/Expr$Binary;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; public fun visitExprCall (Lorg/partiql/ast/Expr$Call;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprCanCast (Lorg/partiql/ast/Expr$CanCast;Ljava/lang/Object;)Ljava/lang/Object; @@ -6407,8 +6448,14 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/visitor/A public fun visitExprLike (Lorg/partiql/ast/Expr$Like;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprLit (Lorg/partiql/ast/Expr$Lit;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprLit (Lorg/partiql/ast/Expr$Lit;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitExprNot (Lorg/partiql/ast/Expr$Not;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprNot (Lorg/partiql/ast/Expr$Not;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprNullIf (Lorg/partiql/ast/Expr$NullIf;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprNullIf (Lorg/partiql/ast/Expr$NullIf;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitExprOperator (Lorg/partiql/ast/Expr$Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprOperator (Lorg/partiql/ast/Expr$Operator;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitExprOr (Lorg/partiql/ast/Expr$Or;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprOr (Lorg/partiql/ast/Expr$Or;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprOverlay (Lorg/partiql/ast/Expr$Overlay;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprOverlay (Lorg/partiql/ast/Expr$Overlay;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprParameter (Lorg/partiql/ast/Expr$Parameter;Ljava/lang/Object;)Ljava/lang/Object; @@ -6439,8 +6486,6 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/visitor/A public fun visitExprSubstring (Lorg/partiql/ast/Expr$Substring;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprTrim (Lorg/partiql/ast/Expr$Trim;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprTrim (Lorg/partiql/ast/Expr$Trim;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; - public synthetic fun visitExprUnary (Lorg/partiql/ast/Expr$Unary;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprUnary (Lorg/partiql/ast/Expr$Unary;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprValues (Lorg/partiql/ast/Expr$Values;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprValues (Lorg/partiql/ast/Expr$Values;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExprValuesRow (Lorg/partiql/ast/Expr$Values$Row;Ljava/lang/Object;)Ljava/lang/Object; @@ -6642,12 +6687,12 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitExcludeStepStructField (Lorg/partiql/ast/Exclude$Step$StructField;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExcludeStepStructWildcard (Lorg/partiql/ast/Exclude$Step$StructWildcard;Ljava/lang/Object;)Ljava/lang/Object; 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 visitExprBinary (Lorg/partiql/ast/Expr$Binary;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprBinary (Lorg/partiql/ast/Expr$Binary;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprCall (Lorg/partiql/ast/Expr$Call;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprCall (Lorg/partiql/ast/Expr$Call;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprCanCast (Lorg/partiql/ast/Expr$CanCast;Ljava/lang/Object;)Ljava/lang/Object; @@ -6682,8 +6727,14 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitExprLit (Lorg/partiql/ast/Expr$Lit;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprMatch (Lorg/partiql/ast/Expr$Match;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprMatch (Lorg/partiql/ast/Expr$Match;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitExprNot (Lorg/partiql/ast/Expr$Not;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprNot (Lorg/partiql/ast/Expr$Not;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprNullIf (Lorg/partiql/ast/Expr$NullIf;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprNullIf (Lorg/partiql/ast/Expr$NullIf;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitExprOperator (Lorg/partiql/ast/Expr$Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprOperator (Lorg/partiql/ast/Expr$Operator;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitExprOr (Lorg/partiql/ast/Expr$Or;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprOr (Lorg/partiql/ast/Expr$Or;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprOverlay (Lorg/partiql/ast/Expr$Overlay;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprOverlay (Lorg/partiql/ast/Expr$Overlay;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprParameter (Lorg/partiql/ast/Expr$Parameter;Ljava/lang/Object;)Ljava/lang/Object; @@ -6714,8 +6765,6 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitExprSubstring (Lorg/partiql/ast/Expr$Substring;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprTrim (Lorg/partiql/ast/Expr$Trim;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprTrim (Lorg/partiql/ast/Expr$Trim;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; - public synthetic fun visitExprUnary (Lorg/partiql/ast/Expr$Unary;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprUnary (Lorg/partiql/ast/Expr$Unary;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprValues (Lorg/partiql/ast/Expr$Values;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprValues (Lorg/partiql/ast/Expr$Values;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitExprValuesRow (Lorg/partiql/ast/Expr$Values$Row;Ljava/lang/Object;)Ljava/lang/Object; @@ -6972,9 +7021,9 @@ public abstract class org/partiql/ast/visitor/AstBaseVisitor : org/partiql/ast/v public fun visitExcludeStepStructField (Lorg/partiql/ast/Exclude$Step$StructField;Ljava/lang/Object;)Ljava/lang/Object; 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 visitExprBinary (Lorg/partiql/ast/Expr$Binary;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; public fun visitExprCanLosslessCast (Lorg/partiql/ast/Expr$CanLosslessCast;Ljava/lang/Object;)Ljava/lang/Object; @@ -6992,7 +7041,10 @@ public abstract class org/partiql/ast/visitor/AstBaseVisitor : org/partiql/ast/v public fun visitExprLike (Lorg/partiql/ast/Expr$Like;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprLit (Lorg/partiql/ast/Expr$Lit;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprMatch (Lorg/partiql/ast/Expr$Match;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprNot (Lorg/partiql/ast/Expr$Not;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprNullIf (Lorg/partiql/ast/Expr$NullIf;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprOperator (Lorg/partiql/ast/Expr$Operator;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitExprOr (Lorg/partiql/ast/Expr$Or;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprOverlay (Lorg/partiql/ast/Expr$Overlay;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprParameter (Lorg/partiql/ast/Expr$Parameter;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprPath (Lorg/partiql/ast/Expr$Path;Ljava/lang/Object;)Ljava/lang/Object; @@ -7009,7 +7061,6 @@ public abstract class org/partiql/ast/visitor/AstBaseVisitor : org/partiql/ast/v public fun visitExprStructField (Lorg/partiql/ast/Expr$Struct$Field;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprSubstring (Lorg/partiql/ast/Expr$Substring;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprTrim (Lorg/partiql/ast/Expr$Trim;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitExprUnary (Lorg/partiql/ast/Expr$Unary;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprValues (Lorg/partiql/ast/Expr$Values;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprValuesRow (Lorg/partiql/ast/Expr$Values$Row;Ljava/lang/Object;)Ljava/lang/Object; public fun visitExprVar (Lorg/partiql/ast/Expr$Var;Ljava/lang/Object;)Ljava/lang/Object; @@ -7165,9 +7216,9 @@ public abstract interface class org/partiql/ast/visitor/AstVisitor { public abstract fun visitExcludeStepStructField (Lorg/partiql/ast/Exclude$Step$StructField;Ljava/lang/Object;)Ljava/lang/Object; 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 visitExprBinary (Lorg/partiql/ast/Expr$Binary;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; public abstract fun visitExprCanLosslessCast (Lorg/partiql/ast/Expr$CanLosslessCast;Ljava/lang/Object;)Ljava/lang/Object; @@ -7185,7 +7236,10 @@ public abstract interface class org/partiql/ast/visitor/AstVisitor { public abstract fun visitExprLike (Lorg/partiql/ast/Expr$Like;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprLit (Lorg/partiql/ast/Expr$Lit;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprMatch (Lorg/partiql/ast/Expr$Match;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitExprNot (Lorg/partiql/ast/Expr$Not;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprNullIf (Lorg/partiql/ast/Expr$NullIf;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitExprOperator (Lorg/partiql/ast/Expr$Operator;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitExprOr (Lorg/partiql/ast/Expr$Or;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprOverlay (Lorg/partiql/ast/Expr$Overlay;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprParameter (Lorg/partiql/ast/Expr$Parameter;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprPath (Lorg/partiql/ast/Expr$Path;Ljava/lang/Object;)Ljava/lang/Object; @@ -7202,7 +7256,6 @@ public abstract interface class org/partiql/ast/visitor/AstVisitor { public abstract fun visitExprStructField (Lorg/partiql/ast/Expr$Struct$Field;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprSubstring (Lorg/partiql/ast/Expr$Substring;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprTrim (Lorg/partiql/ast/Expr$Trim;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitExprUnary (Lorg/partiql/ast/Expr$Unary;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprValues (Lorg/partiql/ast/Expr$Values;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprValuesRow (Lorg/partiql/ast/Expr$Values$Row;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprVar (Lorg/partiql/ast/Expr$Var;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 2549ea6d5..cd25a2fde 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 @@ -336,70 +336,86 @@ private class AstTranslator(val metas: Map) : AstBaseVisi return aggregates.contains(this) } - override fun visitExprUnary(node: Expr.Unary, ctx: Ctx) = translate(node) { metas -> - val arg = visitExpr(node.expr, ctx) - when (node.op) { - Expr.Unary.Op.NOT -> not(arg, metas) - Expr.Unary.Op.POS -> { - when { - arg !is PartiqlAst.Expr.Lit -> pos(arg) - arg.value is IntElement -> arg - arg.value is FloatElement -> arg - arg.value is DecimalElement -> arg - else -> pos(arg) + override fun visitExprOperator(node: Expr.Operator, ctx: Ctx) = translate(node) { metas -> + val lhs = node.lhs?.let { visitExpr(it, ctx) } + val rhs = visitExpr(node.rhs, ctx) + if (lhs == null) { + when (node.symbol) { + "+" -> { + when { + rhs !is PartiqlAst.Expr.Lit -> pos(rhs) + rhs.value is IntElement -> rhs + rhs.value is FloatElement -> rhs + rhs.value is DecimalElement -> rhs + else -> pos(rhs) + } } - } - Expr.Unary.Op.NEG -> { - when { - arg !is PartiqlAst.Expr.Lit -> neg(arg, metas) - arg.value is IntElement -> { - val intValue = when (arg.value.integerSize) { - IntElementSize.LONG -> ionInt(-arg.value.longValue) - IntElementSize.BIG_INTEGER -> when (arg.value.bigIntegerValue) { - Long.MAX_VALUE.toBigInteger() + (1L).toBigInteger() -> ionInt(Long.MIN_VALUE) - else -> ionInt(arg.value.bigIntegerValue * BigInteger.valueOf(-1L)) + "-" -> { + when { + rhs !is PartiqlAst.Expr.Lit -> neg(rhs, metas) + rhs.value is IntElement -> { + val intValue = when (rhs.value.integerSize) { + IntElementSize.LONG -> ionInt(-rhs.value.longValue) + IntElementSize.BIG_INTEGER -> when (rhs.value.bigIntegerValue) { + Long.MAX_VALUE.toBigInteger() + (1L).toBigInteger() -> ionInt(Long.MIN_VALUE) + else -> ionInt(rhs.value.bigIntegerValue * BigInteger.valueOf(-1L)) + } } + rhs.copy( + value = intValue.asAnyElement(), + metas = metas, + ) } - arg.copy( - value = intValue.asAnyElement(), + rhs.value is FloatElement -> rhs.copy( + value = ionFloat(-(rhs.value.doubleValue)).asAnyElement(), + metas = metas, + ) + rhs.value is DecimalElement -> rhs.copy( + value = ionDecimal(Decimal.valueOf(-(rhs.value.decimalValue))).asAnyElement(), metas = metas, ) + else -> neg(rhs, metas) } - arg.value is FloatElement -> arg.copy( - value = ionFloat(-(arg.value.doubleValue)).asAnyElement(), - metas = metas, - ) - arg.value is DecimalElement -> arg.copy( - value = ionDecimal(Decimal.valueOf(-(arg.value.decimalValue))).asAnyElement(), - metas = metas, - ) - else -> neg(arg, metas) } + else -> error("unsupported unary expr operator $node") + } + } else { + val operands = listOf(lhs, rhs) + when (node.symbol) { + "+" -> plus(operands, metas) + "-" -> minus(operands, metas) + "*" -> times(operands, metas) + "/" -> divide(operands, metas) + "%" -> modulo(operands, metas) + "||" -> concat(operands, metas) + "=" -> eq(operands, metas) + "<>" -> ne(operands, metas) + "!=" -> ne(operands, metas) + ">" -> gt(operands, metas) + ">=" -> gte(operands, metas) + "<" -> lt(operands, metas) + "<=" -> lte(operands, metas) + "&" -> bitwiseAnd(operands, metas) + else -> error("unsupported binary expr operator $node") } } } - override fun visitExprBinary(node: Expr.Binary, ctx: Ctx) = translate(node) { metas -> + override fun visitExprAnd(node: Expr.And, ctx: Ctx) = translate(node) { metas -> val lhs = visitExpr(node.lhs, ctx) val rhs = visitExpr(node.rhs, ctx) - val operands = listOf(lhs, rhs) - when (node.op) { - Expr.Binary.Op.PLUS -> plus(operands, metas) - Expr.Binary.Op.MINUS -> minus(operands, metas) - Expr.Binary.Op.TIMES -> times(operands, metas) - Expr.Binary.Op.DIVIDE -> divide(operands, metas) - Expr.Binary.Op.MODULO -> modulo(operands, metas) - Expr.Binary.Op.CONCAT -> concat(operands, metas) - Expr.Binary.Op.AND -> and(operands, metas) - Expr.Binary.Op.OR -> or(operands, metas) - Expr.Binary.Op.EQ -> eq(operands, metas) - Expr.Binary.Op.NE -> ne(operands, metas) - Expr.Binary.Op.GT -> gt(operands, metas) - Expr.Binary.Op.GTE -> gte(operands, metas) - Expr.Binary.Op.LT -> lt(operands, metas) - Expr.Binary.Op.LTE -> lte(operands, metas) - Expr.Binary.Op.BITWISE_AND -> bitwiseAnd(operands, metas) - } + and(lhs, rhs) + } + + override fun visitExprOr(node: Expr.Or, ctx: Ctx) = translate(node) { metas -> + val lhs = visitExpr(node.lhs, ctx) + val rhs = visitExpr(node.rhs, ctx) + or(lhs, rhs) + } + + override fun visitExprNot(node: Expr.Not, ctx: Ctx) = translate(node) { metas -> + val rhs = visitExpr(node.value, ctx) + not(rhs) } override fun visitExprPath(node: Expr.Path, ctx: Ctx) = translate(node) { metas -> 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 97a863566..0b3b18043 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 @@ -229,44 +229,47 @@ public abstract class SqlDialect : AstBaseVisitor() { return head concat r("`$value`") } - override fun visitExprUnary(node: Expr.Unary, head: SqlBlock): SqlBlock { - val op = when (node.op) { - Expr.Unary.Op.NOT -> "NOT (" - Expr.Unary.Op.POS -> "+(" - Expr.Unary.Op.NEG -> "-(" + override fun visitExprOperator(node: Expr.Operator, head: SqlBlock): SqlBlock { + val lhs = node.lhs + return if (lhs != null) { + var h = head + h = visitExprWrapped(node.lhs, h) + h = h concat r(" ${node.symbol} ") + h = visitExprWrapped(node.rhs, h) + h + } else { + var h = head + h = h concat r(node.symbol + "(") + h = visitExprWrapped(node.rhs, h) + h = h concat r(")") + return h } + } + + override fun visitExprAnd(node: Expr.And, head: SqlBlock): SqlBlock { var h = head - h = h concat r(op) - h = visitExprWrapped(node.expr, h) - h = h concat r(")") + h = visitExprWrapped(node.lhs, h) + h = h concat r(" AND ") + h = visitExprWrapped(node.rhs, h) return h } - override fun visitExprBinary(node: Expr.Binary, head: SqlBlock): SqlBlock { - val op = when (node.op) { - Expr.Binary.Op.PLUS -> "+" - Expr.Binary.Op.MINUS -> "-" - Expr.Binary.Op.TIMES -> "*" - Expr.Binary.Op.DIVIDE -> "/" - Expr.Binary.Op.MODULO -> "%" - Expr.Binary.Op.CONCAT -> "||" - Expr.Binary.Op.AND -> "AND" - Expr.Binary.Op.OR -> "OR" - Expr.Binary.Op.EQ -> "=" - Expr.Binary.Op.NE -> "<>" - Expr.Binary.Op.GT -> ">" - Expr.Binary.Op.GTE -> ">=" - Expr.Binary.Op.LT -> "<" - Expr.Binary.Op.LTE -> "<=" - Expr.Binary.Op.BITWISE_AND -> "&" - } + override fun visitExprOr(node: Expr.Or, head: SqlBlock): SqlBlock { var h = head h = visitExprWrapped(node.lhs, h) - h = h concat r(" $op ") + h = h concat r(" OR ") h = visitExprWrapped(node.rhs, h) return h } + override fun visitExprNot(node: Expr.Not, head: SqlBlock): SqlBlock { + var h = head + h = h concat r("NOT (") + h = visitExprWrapped(node.value, h) + h = h concat r(")") + return h + } + override fun visitExprVar(node: Expr.Var, head: SqlBlock): SqlBlock { var h = head // Prepend @ 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 6c93aa009..97917bb9a 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 @@ -255,44 +255,47 @@ internal abstract class InternalSqlDialect : AstBaseVisitor "NOT (" - Expr.Unary.Op.POS -> "+(" - Expr.Unary.Op.NEG -> "-(" + override fun visitExprOperator(node: Expr.Operator, tail: InternalSqlBlock): InternalSqlBlock { + val lhs = node.lhs + return if (lhs != null) { + var t = tail + t = visitExprWrapped(node.lhs, t) + t = t concat " ${node.symbol} " + t = visitExprWrapped(node.rhs, t) + t + } else { + var t = tail + t = t concat node.symbol + "(" + t = visitExprWrapped(node.rhs, t) + t = t concat ")" + return t } + } + + override fun visitExprAnd(node: Expr.And, tail: InternalSqlBlock): InternalSqlBlock { var t = tail - t = t concat op - t = visitExprWrapped(node.expr, t) - t = t concat ")" + t = visitExprWrapped(node.lhs, t) + t = t concat " AND " + t = visitExprWrapped(node.rhs, t) return t } - override fun visitExprBinary(node: Expr.Binary, tail: InternalSqlBlock): InternalSqlBlock { - val op = when (node.op) { - Expr.Binary.Op.PLUS -> "+" - Expr.Binary.Op.MINUS -> "-" - Expr.Binary.Op.TIMES -> "*" - Expr.Binary.Op.DIVIDE -> "/" - Expr.Binary.Op.MODULO -> "%" - Expr.Binary.Op.CONCAT -> "||" - Expr.Binary.Op.AND -> "AND" - Expr.Binary.Op.OR -> "OR" - Expr.Binary.Op.EQ -> "=" - Expr.Binary.Op.NE -> "<>" - Expr.Binary.Op.GT -> ">" - Expr.Binary.Op.GTE -> ">=" - Expr.Binary.Op.LT -> "<" - Expr.Binary.Op.LTE -> "<=" - Expr.Binary.Op.BITWISE_AND -> "&" - } + override fun visitExprOr(node: Expr.Or, tail: InternalSqlBlock): InternalSqlBlock { var t = tail t = visitExprWrapped(node.lhs, t) - t = t concat " $op " + t = t concat " OR " t = visitExprWrapped(node.rhs, t) return t } + override fun visitExprNot(node: Expr.Not, tail: InternalSqlBlock): InternalSqlBlock { + var t = tail + t = t concat "NOT (" + t = visitExprWrapped(node.value, t) + t = t concat ")" + return t + } + override fun visitExprVar(node: Expr.Var, tail: InternalSqlBlock): InternalSqlBlock { var t = tail // Prepend @ diff --git a/partiql-ast/src/main/resources/partiql_ast.ion b/partiql-ast/src/main/resources/partiql_ast.ion index a7b32727f..91368a6a0 100644 --- a/partiql-ast/src/main/resources/partiql_ast.ion +++ b/partiql-ast/src/main/resources/partiql_ast.ion @@ -354,19 +354,26 @@ expr::[ index: int, }, - // Unary Operators - unary::{ - op: [ NOT, POS, NEG ], - expr: expr, + // Operator expr node + operator::{ + symbol: string, + lhs: optional::expr, + rhs: expr }, - // Binary Operators - binary::{ - op: [ - PLUS, MINUS, TIMES, DIVIDE, MODULO, CONCAT, BITWISE_AND, - AND, OR, - EQ, NE, GT, GTE, LT, LTE, - ], + // SQL special form `NOT` + not::{ + value: expr, + }, + + // SQL special form `AND` + and::{ + lhs: expr, + rhs: expr, + }, + + // SQL special form `OR` + or::{ lhs: expr, rhs: expr, }, diff --git a/partiql-ast/src/test/kotlin/org/partiql/ast/helpers/ToLegacyAstTest.kt b/partiql-ast/src/test/kotlin/org/partiql/ast/helpers/ToLegacyAstTest.kt index 440b9911d..8cfc7ae61 100644 --- a/partiql-ast/src/test/kotlin/org/partiql/ast/helpers/ToLegacyAstTest.kt +++ b/partiql-ast/src/test/kotlin/org/partiql/ast/helpers/ToLegacyAstTest.kt @@ -286,27 +286,26 @@ class ToLegacyAstTest { @JvmStatic fun operators() = listOf( expect("(not (lit null))") { - exprUnary { - op = Expr.Unary.Op.NOT - expr = NULL + exprNot { + value = NULL } }, expect("(pos (lit null))") { - exprUnary { - op = Expr.Unary.Op.POS - expr = NULL + exprOperator { + symbol = "+" + rhs = NULL } }, expect("(neg (lit null))") { - exprUnary { - op = Expr.Unary.Op.NEG - expr = NULL + exprOperator { + symbol = "-" + rhs = NULL } }, // we don't really need to test _all_ binary operators expect("(plus (lit null) (lit null))") { - exprBinary { - op = Expr.Binary.Op.PLUS + exprOperator { + symbol = "+" lhs = NULL rhs = NULL } 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 e93e1294f..997f6f7b2 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 @@ -228,65 +228,62 @@ class SqlDialectTest { @JvmStatic fun exprOperators() = listOf( expect("NOT (NULL)") { - exprUnary { - op = Expr.Unary.Op.NOT - expr = NULL + exprNot { + value = NULL } }, expect("+(NULL)") { - exprUnary { - op = Expr.Unary.Op.POS - expr = NULL + exprOperator { + symbol = "+" + rhs = NULL } }, expect("-(NULL)") { - exprUnary { - op = Expr.Unary.Op.NEG - expr = NULL + exprOperator { + symbol = "-" + rhs = NULL } }, expect("NOT (NOT (NULL))") { - exprUnary { - op = Expr.Unary.Op.NOT - expr = exprUnary { - op = Expr.Unary.Op.NOT - expr = NULL + exprNot { + value = exprNot { + value = NULL } } }, expect("+(+(NULL))") { - exprUnary { - op = Expr.Unary.Op.POS - expr = exprUnary { - op = Expr.Unary.Op.POS - expr = NULL + exprOperator { + symbol = "+" + rhs = exprOperator { + symbol = "+" + rhs = NULL } } }, expect("-(-(NULL))") { - exprUnary { - op = Expr.Unary.Op.NEG - expr = exprUnary { - op = Expr.Unary.Op.NEG - expr = NULL + exprOperator { + symbol = "-" + rhs = exprOperator { + symbol = "-" + rhs = NULL } } }, expect("+(-(+(NULL)))") { - exprUnary { - op = Expr.Unary.Op.POS - expr = exprUnary { - op = Expr.Unary.Op.NEG - expr = exprUnary { - op = Expr.Unary.Op.POS - expr = NULL + exprOperator { + symbol = "+" + rhs = exprOperator { + symbol = "-" + rhs = exprOperator { + symbol = "+" + rhs = NULL } } } }, expect("NULL + NULL") { - exprBinary { - op = Expr.Binary.Op.PLUS + exprOperator { + symbol = "+" lhs = NULL rhs = NULL } @@ -538,8 +535,8 @@ class SqlDialectTest { scope = Expr.Var.Scope.DEFAULT } steps += exprPathStepIndex( - exprBinary { - op = Expr.Binary.Op.PLUS + exprOperator { + symbol = "+" lhs = exprLit(int32Value(1)) rhs = exprVar { identifier = id("a") @@ -1738,8 +1735,8 @@ class SqlDialectTest { @JvmStatic private fun subqueryCases() = listOf( expect("1 = (SELECT a FROM T)") { - exprBinary { - op = Expr.Binary.Op.EQ + exprOperator { + symbol = "=" lhs = exprLit(int32Value(1)) rhs = exprSFW { select = select("a") @@ -1748,8 +1745,8 @@ class SqlDialectTest { } }, expect("(1, 2) = (SELECT a FROM T)") { - exprBinary { - op = Expr.Binary.Op.EQ + exprOperator { + symbol = "=" lhs = exprCollection { type = Expr.Collection.Type.LIST values += exprLit(int32Value(1)) 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 b56599ab6..94fc44234 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 @@ -1121,15 +1121,24 @@ internal class PartiQLPigVisitor( override fun visitNot(ctx: PartiQLParser.NotContext) = visitUnaryOperation(ctx.rhs, ctx.op, null) + private fun emptyListIfNull(ctx: ParserRuleContext?) = if (ctx == null) { + emptyList() + } else { + listOf(ctx.start) + } + override fun visitMathOp00(ctx: PartiQLParser.MathOp00Context): PartiqlAst.PartiqlAstNode = - visitBinaryOperation(ctx.lhs, ctx.rhs, listOf(ctx.op), ctx.parent) + visitBinaryOperation(ctx.lhs, ctx.rhs, emptyListIfNull(ctx.op), ctx.parent) - override fun visitMathOp01(ctx: PartiQLParser.MathOp01Context): PartiqlAst.PartiqlAstNode = - visitBinaryOperation(ctx.lhs, ctx.rhs, listOf(ctx.op), ctx.parent) + override fun visitMathOp01(ctx: PartiQLParser.MathOp01Context) = + visitUnaryOperation(ctx.rhs, ctx.op?.start, ctx.parent) override fun visitMathOp02(ctx: PartiQLParser.MathOp02Context): PartiqlAst.PartiqlAstNode = visitBinaryOperation(ctx.lhs, ctx.rhs, listOf(ctx.op), ctx.parent) + override fun visitMathOp03(ctx: PartiQLParser.MathOp03Context): PartiqlAst.PartiqlAstNode = + visitBinaryOperation(ctx.lhs, ctx.rhs, listOf(ctx.op), ctx.parent) + override fun visitValueExpr(ctx: PartiQLParser.ValueExprContext) = visitUnaryOperation(ctx.rhs, ctx.sign, ctx.parent) @@ -1785,25 +1794,30 @@ internal class PartiQLPigVisitor( if (parent != null) return@build visit(parent) as PartiqlAst.Expr val args = listOf(lhs!!, rhs!!).map { visit(it) as PartiqlAst.Expr } val metas = op.getSourceMetaContainer() - when (op.first().type) { - PartiQLParser.AND -> and(args, metas) - PartiQLParser.OR -> or(args, metas) - PartiQLParser.ASTERISK -> times(args, metas) - PartiQLParser.SLASH_FORWARD -> divide(args, metas) - PartiQLParser.PLUS -> plus(args, metas) - PartiQLParser.MINUS -> minus(args, metas) - PartiQLParser.PERCENT -> modulo(args, metas) - PartiQLParser.CONCAT -> concat(args, metas) - PartiQLParser.ANGLE_LEFT -> { - if (op.size > 1) ne(args, metas) - else lt(args, metas) - } - PartiQLParser.LT_EQ -> lte(args, metas) - PartiQLParser.ANGLE_RIGHT -> gt(args, metas) - PartiQLParser.GT_EQ -> gte(args, metas) - PartiQLParser.BANG -> ne(args, metas) - PartiQLParser.EQ -> eq(args, metas) - PartiQLParser.AMPERSAND -> bitwiseAnd(args, metas) + val start = op.first().tokenIndex + val stop = op.last().tokenIndex + val tokensInRange = tokens.get(start, stop) + if (tokensInRange.any { it.channel == PartiQLTokens.HIDDEN }) { + throw ParserException("Invalid whitespace or comment in operator", ErrorCode.PARSE_INVALID_QUERY) + } + val stringOp = op.joinToString("") { it.text.lowercase() } + when (stringOp) { + "and" -> and(args, metas) + "or" -> or(args, metas) + "*" -> times(args, metas) + "/" -> divide(args, metas) + "+" -> plus(args, metas) + "-" -> minus(args, metas) + "%" -> modulo(args, metas) + "||" -> concat(args, metas) + "<" -> lt(args, metas) + "<>" -> ne(args, metas) + "<=" -> lte(args, metas) + ">" -> gt(args, metas) + ">=" -> gte(args, metas) + "!=" -> ne(args, metas) + "=" -> eq(args, metas) + "&" -> bitwiseAnd(args, metas) else -> throw ParserException("Unknown binary operator", ErrorCode.PARSE_INVALID_QUERY) } } @@ -1843,7 +1857,6 @@ internal class PartiQLPigVisitor( else -> neg(arg, metas) } } - PartiQLParser.NOT -> not(arg, metas) else -> throw ParserException("Unknown unary operator", ErrorCode.PARSE_INVALID_QUERY) } diff --git a/partiql-lang/src/test/kotlin/org/partiql/lang/syntax/PartiQLParserTest.kt b/partiql-lang/src/test/kotlin/org/partiql/lang/syntax/PartiQLParserTest.kt index 98fc988f0..59d22541f 100644 --- a/partiql-lang/src/test/kotlin/org/partiql/lang/syntax/PartiQLParserTest.kt +++ b/partiql-lang/src/test/kotlin/org/partiql/lang/syntax/PartiQLParserTest.kt @@ -5053,4 +5053,69 @@ class PartiQLParserTest : PartiQLParserTestBase() { Property.TOKEN_VALUE to ION.newSymbol("<") ) ) + + // regression tests for neq operator + @Test + fun testNeqOp() = assertExpression("1 <> 2") { + ne( + lit(ionInt(1)), + lit(ionInt(2)) + ) + } + + @Test + fun testNeqOpAlt() = assertExpression("1 != 2") { + ne( + lit(ionInt(1)), + lit(ionInt(2)) + ) + } + + @Test + fun testSpacesInNeq() = checkInputThrowingParserException( + "1 < > 2", + ErrorCode.PARSE_UNEXPECTED_TOKEN, // partiql-ast parser ErrorCode + expectErrorContextValues = mapOf( + Property.LINE_NUMBER to 1L, + Property.COLUMN_NUMBER to 3L, + Property.TOKEN_DESCRIPTION to PartiQLParser.ANGLE_LEFT.getAntlrDisplayString(), + Property.TOKEN_VALUE to ION.newSymbol("<") + ) + ) + + @Test + fun testSpacesInNeqAlt() = checkInputThrowingParserException( + "1 ! = 2", + ErrorCode.PARSE_UNEXPECTED_TOKEN, // partiql-ast parser ErrorCode + expectErrorContextValues = mapOf( + Property.LINE_NUMBER to 1L, + Property.COLUMN_NUMBER to 3L, + Property.TOKEN_DESCRIPTION to PartiQLParser.BANG.getAntlrDisplayString(), + Property.TOKEN_VALUE to ION.newSymbol("!") + ) + ) + + @Test + fun testCommentsInNeq() = checkInputThrowingParserException( + "1 2", + ErrorCode.PARSE_UNEXPECTED_TOKEN, // partiql-ast parser ErrorCode + expectErrorContextValues = mapOf( + Property.LINE_NUMBER to 1L, + Property.COLUMN_NUMBER to 3L, + Property.TOKEN_DESCRIPTION to PartiQLParser.ANGLE_LEFT.getAntlrDisplayString(), + Property.TOKEN_VALUE to ION.newSymbol("<") + ) + ) + + @Test + fun testCommentsInNeqAlt() = checkInputThrowingParserException( + "1 !/* some comment*/= 2", + ErrorCode.PARSE_UNEXPECTED_TOKEN, // partiql-ast parser ErrorCode + expectErrorContextValues = mapOf( + Property.LINE_NUMBER to 1L, + Property.COLUMN_NUMBER to 3L, + Property.TOKEN_DESCRIPTION to PartiQLParser.BANG.getAntlrDisplayString(), + Property.TOKEN_VALUE to ION.newSymbol("!") + ) + ) } diff --git a/partiql-parser/src/main/antlr/PartiQLParser.g4 b/partiql-parser/src/main/antlr/PartiQLParser.g4 index 49f076bf2..54be03c23 100644 --- a/partiql-parser/src/main/antlr/PartiQLParser.g4 +++ b/partiql-parser/src/main/antlr/PartiQLParser.g4 @@ -619,20 +619,32 @@ comparisonOp | BANG EQ ; -// TODO : Opreator precedence of BITWISE_AND (&) may change in the future. +otherOp + : OPERATOR + | AMPERSAND + // TODO introduce a separate lexical mode for GPML MATCH expressions (https://github.com/partiql/partiql-lang-kotlin/issues/1512) + // This will eliminiate the need for this `AMPERSAND` parse branch. + ; + +// TODO : Opreator precedence of `otherOp` may change in the future. // SEE: https://github.com/partiql/partiql-docs/issues/50 mathOp00 - : lhs=mathOp00 op=(AMPERSAND|CONCAT) rhs=mathOp01 + : lhs=mathOp00 op=otherOp rhs=mathOp01 | parent=mathOp01 ; mathOp01 - : lhs=mathOp01 op=(PLUS|MINUS) rhs=mathOp02 + : op=otherOp rhs=mathOp02 | parent=mathOp02 ; mathOp02 - : lhs=mathOp02 op=(PERCENT|ASTERISK|SLASH_FORWARD) rhs=valueExpr + : lhs=mathOp02 op=(PLUS|MINUS) rhs=mathOp03 + | parent=mathOp03 + ; + +mathOp03 + : lhs=mathOp03 op=(PERCENT|ASTERISK|SLASH_FORWARD) rhs=valueExpr | parent=valueExpr ; diff --git a/partiql-parser/src/main/antlr/PartiQLTokens.g4 b/partiql-parser/src/main/antlr/PartiQLTokens.g4 index 28c1581da..20e2d9425 100644 --- a/partiql-parser/src/main/antlr/PartiQLTokens.g4 +++ b/partiql-parser/src/main/antlr/PartiQLTokens.g4 @@ -337,7 +337,6 @@ BANG: '!'; LT_EQ: '<='; GT_EQ: '>='; EQ: '='; -CONCAT: '||'; ANGLE_LEFT: '<'; ANGLE_RIGHT: '>'; BRACKET_LEFT: '['; @@ -351,6 +350,36 @@ COLON: ':'; COLON_SEMI: ';'; QUESTION_MARK: '?'; PERIOD: '.'; +HASH: '#'; + +// Operators w/ special characters +// Similar to postgresql's supported operator creation -- https://www.postgresql.org/docs/16/sql-createoperator.html +OPERATOR + // may not end with + or - + : OpBasic+ OpBasicEnd + // must include at least one of OpSpecial to end w/ anything + | (OpBasic | OpSpecial)* OpSpecial (OpBasic | OpSpecial)* + ; + +fragment OpBasic + : [+*=] // TODO support `<` and `>`? + // comments are not matched + | '-' {_input.LA(1) != '-'}? + | '/' {_input.LA(1) != '*'}? + ; + +fragment OpBasicEnd + : [*/=] // TODO support `<` and `>`? + ; +fragment OpSpecial + : [~@#%^?] // TODO support backtick (`)? + // graph patterns are not matched + // TODO make GPML MATCH patterns a separate lexical mode (https://github.com/partiql/partiql-lang-kotlin/issues/1512) + // Creating a separate lexical mode will allow us to get rid of the following semantic predicates. + | '|' {_input.LA(1) != '!'}? + | '!' {_input.LA(1) != '%'}? + | '&' {_input.LA(1) != '%'}? + ; /** * 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 19bdef2d9..ab893442d 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 @@ -68,9 +68,9 @@ import org.partiql.ast.excludeStepCollIndex 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.exprBinary import org.partiql.ast.exprCall import org.partiql.ast.exprCanCast import org.partiql.ast.exprCanLosslessCast @@ -88,7 +88,10 @@ import org.partiql.ast.exprIsType import org.partiql.ast.exprLike import org.partiql.ast.exprLit import org.partiql.ast.exprMatch +import org.partiql.ast.exprNot import org.partiql.ast.exprNullIf +import org.partiql.ast.exprOperator +import org.partiql.ast.exprOr import org.partiql.ast.exprOverlay import org.partiql.ast.exprParameter import org.partiql.ast.exprPath @@ -103,7 +106,6 @@ import org.partiql.ast.exprStruct import org.partiql.ast.exprStructField import org.partiql.ast.exprSubstring import org.partiql.ast.exprTrim -import org.partiql.ast.exprUnary import org.partiql.ast.exprVar import org.partiql.ast.exprWindow import org.partiql.ast.exprWindowOver @@ -1565,83 +1567,75 @@ internal class PartiQLParserDefault : PartiQLParser { */ override fun visitOr(ctx: GeneratedParser.OrContext) = translate(ctx) { - convertBinaryExpr(ctx.lhs, ctx.rhs, Expr.Binary.Op.OR) + val l = visit(ctx.lhs) as Expr + val r = visit(ctx.rhs) as Expr + exprOr(l, r) } override fun visitAnd(ctx: GeneratedParser.AndContext) = translate(ctx) { - convertBinaryExpr(ctx.lhs, ctx.rhs, Expr.Binary.Op.AND) + val l = visit(ctx.lhs) as Expr + val r = visit(ctx.rhs) as Expr + exprAnd(l, r) } override fun visitNot(ctx: GeneratedParser.NotContext) = translate(ctx) { val expr = visit(ctx.exprNot()) as Expr - exprUnary(Expr.Unary.Op.NOT, expr) + exprNot(expr) + } + + private fun checkForInvalidTokens(op: ParserRuleContext) { + val start = op.start.tokenIndex + val stop = op.stop.tokenIndex + val tokensInRange = tokens.get(start, stop) + if (tokensInRange.any { it.channel == GeneratedLexer.HIDDEN }) { + throw error(op, "Invalid whitespace or comment in operator") + } + } + + private fun convertToOperator(value: ParserRuleContext, op: ParserRuleContext): Expr { + checkForInvalidTokens(op) + return convertToOperator(value, op.text) + } + + private fun convertToOperator(value: ParserRuleContext, op: String): Expr { + val v = visit(value) as Expr + return exprOperator(op, null, v) + } + + private fun convertToOperator(lhs: ParserRuleContext, rhs: ParserRuleContext, op: ParserRuleContext): Expr { + checkForInvalidTokens(op) + return convertToOperator(lhs, rhs, op.text) + } + + private fun convertToOperator(lhs: ParserRuleContext, rhs: ParserRuleContext, op: String): Expr { + val l = visit(lhs) as Expr + val r = visit(rhs) as Expr + return exprOperator(op, l, r) } override fun visitMathOp00(ctx: GeneratedParser.MathOp00Context) = translate(ctx) { if (ctx.parent != null) return@translate visit(ctx.parent) - convertBinaryExpr(ctx.lhs, ctx.rhs, convertBinaryMathOp(ctx.op)) + convertToOperator(ctx.lhs, ctx.rhs, ctx.op) } override fun visitMathOp01(ctx: GeneratedParser.MathOp01Context) = translate(ctx) { if (ctx.parent != null) return@translate visit(ctx.parent) - convertBinaryExpr(ctx.lhs, ctx.rhs, convertBinaryMathOp(ctx.op)) + convertToOperator(ctx.rhs, ctx.op) } override fun visitMathOp02(ctx: GeneratedParser.MathOp02Context) = translate(ctx) { if (ctx.parent != null) return@translate visit(ctx.parent) - convertBinaryExpr(ctx.lhs, ctx.rhs, convertBinaryMathOp(ctx.op)) + convertToOperator(ctx.lhs, ctx.rhs, ctx.op.text) } - override fun visitValueExpr(ctx: GeneratedParser.ValueExprContext) = translate(ctx) { + override fun visitMathOp03(ctx: GeneratedParser.MathOp03Context) = translate(ctx) { if (ctx.parent != null) return@translate visit(ctx.parent) - val expr = visit(ctx.rhs) as Expr - exprUnary(convertUnaryOp(ctx.sign), expr) + convertToOperator(ctx.lhs, ctx.rhs, ctx.op.text) } - private fun convertBinaryExpr(lhs: ParserRuleContext, rhs: ParserRuleContext, op: Expr.Binary.Op): Expr { - val l = visit(lhs) as Expr - val r = visit(rhs) as Expr - return exprBinary(op, l, r) - } - - private fun convertBinaryOp(ctx: GeneratedParser.ComparisonOpContext) = when (ctx.start.type) { - GeneratedParser.AMPERSAND -> Expr.Binary.Op.BITWISE_AND - GeneratedParser.AND -> Expr.Binary.Op.AND - GeneratedParser.OR -> Expr.Binary.Op.OR - GeneratedParser.ASTERISK -> Expr.Binary.Op.TIMES - GeneratedParser.SLASH_FORWARD -> Expr.Binary.Op.DIVIDE - GeneratedParser.PLUS -> Expr.Binary.Op.PLUS - GeneratedParser.MINUS -> Expr.Binary.Op.MINUS - GeneratedParser.PERCENT -> Expr.Binary.Op.MODULO - GeneratedParser.CONCAT -> Expr.Binary.Op.CONCAT - GeneratedParser.ANGLE_LEFT -> { - if (ctx.stop.type == GeneratedParser.ANGLE_RIGHT) Expr.Binary.Op.NE - else Expr.Binary.Op.LT - } - GeneratedParser.LT_EQ -> Expr.Binary.Op.LTE - GeneratedParser.ANGLE_RIGHT -> Expr.Binary.Op.GT - GeneratedParser.GT_EQ -> Expr.Binary.Op.GTE - GeneratedParser.BANG -> Expr.Binary.Op.NE - GeneratedParser.EQ -> Expr.Binary.Op.EQ - else -> throw error(ctx.start, "Invalid binary operator") - } - - private fun convertBinaryMathOp(token: Token) = when (token.type) { - GeneratedParser.AMPERSAND -> Expr.Binary.Op.BITWISE_AND - GeneratedParser.CONCAT -> Expr.Binary.Op.CONCAT - GeneratedParser.PLUS -> Expr.Binary.Op.PLUS - GeneratedParser.MINUS -> Expr.Binary.Op.MINUS - GeneratedParser.PERCENT -> Expr.Binary.Op.MODULO - GeneratedParser.ASTERISK -> Expr.Binary.Op.TIMES - GeneratedParser.SLASH_FORWARD -> Expr.Binary.Op.DIVIDE - else -> throw error(token, "Invalid binary operator") - } - - private fun convertUnaryOp(token: Token) = when (token.type) { - GeneratedParser.PLUS -> Expr.Unary.Op.POS - GeneratedParser.MINUS -> Expr.Unary.Op.NEG - GeneratedParser.NOT -> Expr.Unary.Op.NOT - else -> throw error(token, "Invalid unary operator") + override fun visitValueExpr(ctx: GeneratedParser.ValueExprContext) = translate(ctx) { + if (ctx.parent != null) return@translate visit(ctx.parent) + convertToOperator(ctx.rhs, ctx.sign.text) } /** @@ -1651,8 +1645,7 @@ internal class PartiQLParserDefault : PartiQLParser { */ override fun visitPredicateComparison(ctx: GeneratedParser.PredicateComparisonContext) = translate(ctx) { - val op = convertBinaryOp(ctx.op) - convertBinaryExpr(ctx.lhs, ctx.rhs, op) + convertToOperator(ctx.lhs, ctx.rhs, ctx.op) } /** @@ -1859,7 +1852,7 @@ internal class PartiQLParserDefault : PartiQLParser { when (val funcName = ctx.qualifiedName()) { is GeneratedParser.QualifiedNameContext -> { when (funcName.name.start.type) { - GeneratedParser.MOD -> exprBinary(Expr.Binary.Op.MODULO, args[0], args[1]) + GeneratedParser.MOD -> exprOperator("%", args[0], args[1]) GeneratedParser.CHARACTER_LENGTH, GeneratedParser.CHAR_LENGTH -> { val path = ctx.qualifiedName().qualifier.map { visitSymbolPrimitive(it) } val name = identifierSymbol("char_length", Identifier.CaseSensitivity.INSENSITIVE) diff --git a/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserDDLTests.kt b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserDDLTests.kt index 7eea0be96..48709c800 100644 --- a/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserDDLTests.kt +++ b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserDDLTests.kt @@ -18,8 +18,8 @@ import org.partiql.ast.constraintDefinitionNotNull import org.partiql.ast.constraintDefinitionUnique import org.partiql.ast.ddlOpCreateTable import org.partiql.ast.ddlOpDropTable -import org.partiql.ast.exprBinary import org.partiql.ast.exprLit +import org.partiql.ast.exprOperator import org.partiql.ast.exprVar import org.partiql.ast.identifierQualified import org.partiql.ast.identifierSymbol @@ -219,8 +219,8 @@ class PartiQLParserDDLTests { constraint( null, constraintDefinitionCheck( - exprBinary( - Expr.Binary.Op.GT, + exprOperator( + ">", exprVar(identifierSymbol("a", Identifier.CaseSensitivity.INSENSITIVE), Expr.Var.Scope.DEFAULT), exprLit(int32Value(0)) ) @@ -311,8 +311,8 @@ class PartiQLParserDDLTests { constraint( null, constraintDefinitionCheck( - exprBinary( - Expr.Binary.Op.GT, + exprOperator( + ">", exprVar(identifierSymbol("a", Identifier.CaseSensitivity.INSENSITIVE), Expr.Var.Scope.DEFAULT), exprLit(int32Value(0)) ) diff --git a/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserOperatorTests.kt b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserOperatorTests.kt new file mode 100644 index 000000000..e05f33551 --- /dev/null +++ b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserOperatorTests.kt @@ -0,0 +1,73 @@ +package org.partiql.parser.internal + +import org.junit.jupiter.api.Test +import org.partiql.ast.AstNode +import org.partiql.ast.Expr +import org.partiql.ast.exprLit +import org.partiql.ast.exprOperator +import org.partiql.ast.statementQuery +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.int32Value +import kotlin.test.assertEquals + +@OptIn(PartiQLValueExperimental::class) +class PartiQLParserOperatorTests { + + private val parser = PartiQLParserDefault() + + private inline fun query(body: () -> Expr) = statementQuery(body()) + + @Test + fun builtinUnaryOperator() = assertExpression( + "-2", + query { + exprOperator( + symbol = "-", + lhs = null, + rhs = exprLit(int32Value(2)) + ) + } + ) + + @Test + fun builtinBinaryOperator() = assertExpression( + "1 <= 2", + query { + exprOperator( + symbol = "<=", + lhs = exprLit(int32Value(1)), + rhs = exprLit(int32Value(2)) + ) + } + ) + + @Test + fun customUnaryOperator() = assertExpression( + "==!2", + query { + exprOperator( + symbol = "==!", + lhs = null, + rhs = exprLit(int32Value(2)) + ) + } + ) + + @Test + fun customBinaryOperator() = assertExpression( + "1 ==! 2", + query { + exprOperator( + symbol = "==!", + lhs = exprLit(int32Value(1)), + rhs = exprLit(int32Value(2)) + ) + } + ) + + private fun assertExpression(input: String, expected: AstNode) { + val result = parser.parse(input) + val actual = result.root + assertEquals(expected, actual) + } +} diff --git a/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt index 7d02f659f..2ec95b2d7 100644 --- a/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt +++ b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt @@ -3,8 +3,8 @@ package org.partiql.parser.internal import org.junit.jupiter.api.Test import org.partiql.ast.AstNode import org.partiql.ast.Expr -import org.partiql.ast.exprBinary import org.partiql.ast.exprLit +import org.partiql.ast.exprOperator import org.partiql.ast.exprSessionAttribute import org.partiql.ast.statementQuery import org.partiql.value.PartiQLValueExperimental @@ -46,8 +46,8 @@ class PartiQLParserSessionAttributeTests { fun currentUserEquals() = assertExpression( "1 = current_user", query { - exprBinary( - op = Expr.Binary.Op.EQ, + exprOperator( + symbol = "=", lhs = exprLit(int32Value(1)), rhs = exprSessionAttribute(Expr.SessionAttribute.Attribute.CURRENT_USER) ) 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 330397672..26e6c90a7 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 @@ -147,65 +147,131 @@ internal object RexConverter { return rex(type, op) } - override fun visitExprUnary(node: Expr.Unary, context: Env): Rex { + private fun resolveUnaryOp(symbol: String, rhs: Expr, context: Env): Rex { val type = (ANY) // Args - val arg = visitExprCoerce(node.expr, context) + val arg = visitExprCoerce(rhs, context) val args = listOf(arg) // Fn - val id = identifierSymbol(node.op.name.lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val name = when (symbol) { + // TODO move hard-coded operator resolution into SPI + "+" -> "pos" + "-" -> "neg" + else -> error("unsupported unary op $symbol") + } + val id = identifierSymbol(name.lowercase(), Identifier.CaseSensitivity.INSENSITIVE) val op = rexOpCallUnresolved(id, args) return rex(type, op) } - override fun visitExprBinary(node: Expr.Binary, context: Env): Rex { + private fun resolveBinaryOp(lhs: Expr, symbol: String, rhs: Expr, context: Env): Rex { val type = (ANY) - val args = when (node.op) { - Expr.Binary.Op.LT, Expr.Binary.Op.GT, - Expr.Binary.Op.LTE, Expr.Binary.Op.GTE, - Expr.Binary.Op.EQ, Expr.Binary.Op.NE -> { + val args = when (symbol) { + "<", ">", + "<=", ">=", + "=", "<>", "!=" -> { when { // Example: [1, 2] < (SELECT a, b FROM t) - isLiteralArray(node.lhs) && isSqlSelect(node.rhs) -> { - val lhs = visitExprCoerce(node.lhs, context) - val rhs = visitExprCoerce(node.rhs, context, Rex.Op.Subquery.Coercion.ROW) - listOf(lhs, rhs) + isLiteralArray(lhs) && isSqlSelect(rhs) -> { + val l = visitExprCoerce(lhs, context) + val r = visitExprCoerce(rhs, context, Rex.Op.Subquery.Coercion.ROW) + listOf(l, r) } // Example: (SELECT a, b FROM t) < [1, 2] - isSqlSelect(node.lhs) && isLiteralArray(node.rhs) -> { - val lhs = visitExprCoerce(node.lhs, context, Rex.Op.Subquery.Coercion.ROW) - val rhs = visitExprCoerce(node.rhs, context) - listOf(lhs, rhs) + isSqlSelect(lhs) && isLiteralArray(rhs) -> { + val l = visitExprCoerce(lhs, context, Rex.Op.Subquery.Coercion.ROW) + val r = visitExprCoerce(rhs, context) + listOf(l, r) } // Example: 1 < 2 else -> { - val lhs = visitExprCoerce(node.lhs, context) - val rhs = visitExprCoerce(node.rhs, context) - listOf(lhs, rhs) + val l = visitExprCoerce(lhs, context) + val r = visitExprCoerce(rhs, context) + listOf(l, r) } } } // Example: 1 + 2 else -> { - val lhs = visitExprCoerce(node.lhs, context) - val rhs = visitExprCoerce(node.rhs, context) - listOf(lhs, rhs) + val l = visitExprCoerce(lhs, context) + val r = visitExprCoerce(rhs, context) + listOf(l, r) } } - // Wrap if a NOT if necessary - return when (node.op) { - Expr.Binary.Op.NE -> { + // Wrap if a NOT, if necessary + return when (symbol) { + "<>", "!=" -> { val op = negate(call("eq", *args.toTypedArray())) rex(type, op) } else -> { - val id = identifierSymbol(node.op.name.lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val name = when (symbol) { + // TODO eventually move hard-coded operator resolution into SPI + "<" -> "lt" + ">" -> "gt" + "<=" -> "lte" + ">=" -> "gte" + "=" -> "eq" + "||" -> "concat" + "+" -> "plus" + "-" -> "minus" + "*" -> "times" + "/" -> "divide" + "%" -> "modulo" + "&" -> "bitwise_and" + else -> error("unsupported binary op $symbol") + } + val id = identifierSymbol(name.lowercase(), Identifier.CaseSensitivity.INSENSITIVE) val op = rexOpCallUnresolved(id, args) rex(type, op) } } } + override fun visitExprOperator(node: Expr.Operator, ctx: Env): Rex { + val lhs = node.lhs + return if (lhs != null) { + resolveBinaryOp(lhs, node.symbol, node.rhs, ctx) + } else { + resolveUnaryOp(node.symbol, node.rhs, ctx) + } + } + + override fun visitExprNot(node: Expr.Not, ctx: Env): Rex { + val type = (ANY) + // Args + val arg = visitExprCoerce(node.value, ctx) + val args = listOf(arg) + // Fn + val id = identifierSymbol("not".lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val op = rexOpCallUnresolved(id, args) + return rex(type, op) + } + + override fun visitExprAnd(node: Expr.And, ctx: Env): Rex { + val type = (ANY) + val l = visitExprCoerce(node.lhs, ctx) + val r = visitExprCoerce(node.rhs, ctx) + val args = listOf(l, r) + + // Wrap if a NOT, if necessary + val id = identifierSymbol("and".lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val op = rexOpCallUnresolved(id, args) + return rex(type, op) + } + + override fun visitExprOr(node: Expr.Or, ctx: Env): Rex { + val type = (ANY) + val l = visitExprCoerce(node.lhs, ctx) + val r = visitExprCoerce(node.rhs, ctx) + val args = listOf(l, r) + + // Wrap if a NOT, if necessary + val id = identifierSymbol("or".lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val op = rexOpCallUnresolved(id, args) + return rex(type, op) + } + 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 && @@ -440,7 +506,7 @@ internal object RexConverter { } // Converts AST CASE (x) WHEN y THEN z --> Plan CASE WHEN x = y THEN z - val id = identifierSymbol(Expr.Binary.Op.EQ.name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) + val id = identifierSymbol("eq", Identifier.CaseSensitivity.SENSITIVE) val createBranch: (Rex, Rex) -> Rex.Op.Case.Branch = { condition: Rex, result: Rex -> val updatedCondition = when (rex) { null -> condition @@ -879,8 +945,7 @@ internal object RexConverter { // Helpers private fun negate(call: Rex.Op.Call): Rex.Op.Call { - val name = Expr.Unary.Op.NOT.name - val id = identifierSymbol(name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) + val id = identifierSymbol("not", Identifier.CaseSensitivity.SENSITIVE) // wrap val arg = rex(BOOL, call) // rewrite call