From d43ee11e11f66c1fdfaec5e274a8f48fa6bdbb49 Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Thu, 17 Oct 2024 15:47:46 -0700 Subject: [PATCH 1/2] [v1] Add AST factory methods --- partiql-ast/api/partiql-ast.api | 100 +++- .../src/main/java/org/partiql/ast/v1/Ast.java | 481 ++++++++++++++++++ .../java/org/partiql/ast/v1/AstVisitor.java | 2 +- .../java/org/partiql/ast/v1/QueryBody.java | 10 +- .../java/org/partiql/ast/v1/SelectItem.java | 4 +- .../org/partiql/ast/v1/graph/GraphLabel.java | 2 + .../partiql/ast/v1/graph/GraphQuantifier.java | 5 +- .../partiql/ast/v1/graph/GraphSelector.java | 6 + 8 files changed, 595 insertions(+), 15 deletions(-) create mode 100644 partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index 2b105b8634..d6e8bcde7a 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -5543,6 +5543,94 @@ public abstract class org/partiql/ast/util/AstRewriter : org/partiql/ast/visitor public fun visitTypeVarchar (Lorg/partiql/ast/Type$Varchar;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; } +public class org/partiql/ast/v1/Ast { + public fun ()V + public static fun exclude (Ljava/util/List;)Lorg/partiql/ast/v1/Exclude; + public static fun excludePath (Lorg/partiql/ast/v1/expr/ExprVarRef;Ljava/util/List;)Lorg/partiql/ast/v1/ExcludePath; + public static fun excludeStepCollIndex (I)Lorg/partiql/ast/v1/ExcludeStep$CollIndex; + public static fun excludeStepCollWildcard ()Lorg/partiql/ast/v1/ExcludeStep$CollWildcard; + public static fun excludeStepStructField (Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/ExcludeStep$StructField; + public static fun excludeStepStructWildcard ()Lorg/partiql/ast/v1/ExcludeStep$StructWildcard; + public static fun explain (Ljava/util/Map;Lorg/partiql/ast/v1/Statement;)Lorg/partiql/ast/v1/Explain; + public static fun exprAnd (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprAnd; + public static fun exprArray (Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprArray; + public static fun exprBag (Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprBag; + public static fun exprBetween (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Z)Lorg/partiql/ast/v1/expr/ExprBetween; + public static fun exprCall (Lorg/partiql/ast/v1/IdentifierChain;Ljava/util/List;Lorg/partiql/ast/v1/SetQuantifier;)Lorg/partiql/ast/v1/expr/ExprCall; + public static fun exprCase (Lorg/partiql/ast/v1/expr/Expr;Ljava/util/List;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprCase; + public static fun exprCaseBranch (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprCase$Branch; + public static fun exprCast (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/DataType;)Lorg/partiql/ast/v1/expr/ExprCast; + public static fun exprCoalesce (Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprCoalesce; + public static fun exprExtract (Lorg/partiql/ast/v1/DatetimeField;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprExtract; + public static fun exprInCollection (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Z)Lorg/partiql/ast/v1/expr/ExprInCollection; + public static fun exprIsType (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/DataType;Z)Lorg/partiql/ast/v1/expr/ExprIsType; + public static fun exprLike (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Z)Lorg/partiql/ast/v1/expr/ExprLike; + public static fun exprLit (Lorg/partiql/value/PartiQLValue;)Lorg/partiql/ast/v1/expr/ExprLit; + public static fun exprMatch (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/graph/GraphMatch;)Lorg/partiql/ast/v1/expr/ExprMatch; + public static fun exprNot (Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprNot; + public static fun exprNullIf (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprNullIf; + public static fun exprOperator (Ljava/lang/String;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprOperator; + public static fun exprOr (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprOr; + public static fun exprOverlay (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprOverlay; + public static fun exprParameter (I)Lorg/partiql/ast/v1/expr/ExprParameter; + public static fun exprPath (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/PathStep;)Lorg/partiql/ast/v1/expr/ExprPath; + public static fun exprPathStepAllElements (Lorg/partiql/ast/v1/expr/PathStep;)Lorg/partiql/ast/v1/expr/PathStep$AllElements; + public static fun exprPathStepAllFields (Lorg/partiql/ast/v1/expr/PathStep;)Lorg/partiql/ast/v1/expr/PathStep$AllFields; + public static fun exprPathStepElement (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/PathStep;)Lorg/partiql/ast/v1/expr/PathStep$Element; + public static fun exprPathStepField (Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/expr/PathStep;)Lorg/partiql/ast/v1/expr/PathStep$Field; + public static fun exprPosition (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprPosition; + public static fun exprQuerySet (Lorg/partiql/ast/v1/QueryBody;Lorg/partiql/ast/v1/OrderBy;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprQuerySet; + public static fun exprSessionAttribute (Lorg/partiql/ast/v1/expr/SessionAttribute;)Lorg/partiql/ast/v1/expr/ExprSessionAttribute; + public static fun exprStruct (Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprStruct; + public static fun exprStructField (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprStruct$Field; + public static fun exprSubstring (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/expr/ExprSubstring; + public static fun exprTrim (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/TrimSpec;)Lorg/partiql/ast/v1/expr/ExprTrim; + public static fun exprValues (Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprValues; + public static fun exprValuesRow (Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprValues$Row; + public static fun exprVarRef (Lorg/partiql/ast/v1/IdentifierChain;Lorg/partiql/ast/v1/expr/Scope;)Lorg/partiql/ast/v1/expr/ExprVarRef; + public static fun exprVariant (Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/ast/v1/expr/ExprVariant; + public static fun exprWindow (Lorg/partiql/ast/v1/expr/WindowFunction;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/ExprWindow$Over;)Lorg/partiql/ast/v1/expr/ExprWindow; + public static fun exprWindowOver (Ljava/util/List;Ljava/util/List;)Lorg/partiql/ast/v1/expr/ExprWindow$Over; + public static fun from (Ljava/util/List;)Lorg/partiql/ast/v1/From; + public static fun fromExpr (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/FromType;Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/FromExpr; + public static fun fromJoin (Lorg/partiql/ast/v1/From;Lorg/partiql/ast/v1/From;Lorg/partiql/ast/v1/JoinType;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/FromJoin; + public static fun graphLabelConj (Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphLabel$Conj; + public static fun graphLabelDisj (Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphLabel$Disj; + public static fun graphLabelName (Ljava/lang/String;)Lorg/partiql/ast/v1/graph/GraphLabel$Name; + public static fun graphLabelNegation (Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Negation; + public static fun graphLabelWildcard ()Lorg/partiql/ast/v1/graph/GraphLabel$Wildcard; + public static fun graphMatch (Ljava/util/List;Lorg/partiql/ast/v1/graph/GraphSelector;)Lorg/partiql/ast/v1/graph/GraphMatch; + public static fun graphMatchEdge (Lorg/partiql/ast/v1/graph/GraphDirection;Lorg/partiql/ast/v1/graph/GraphQuantifier;Lorg/partiql/ast/v1/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphPart$Edge; + public static fun graphMatchNode (Lorg/partiql/ast/v1/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphPart$Node; + public static fun graphMatchPattern (Lorg/partiql/ast/v1/graph/GraphPattern;)Lorg/partiql/ast/v1/graph/GraphPart$Pattern; + public static fun graphPattern (Lorg/partiql/ast/v1/graph/GraphRestrictor;Lorg/partiql/ast/v1/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/v1/graph/GraphQuantifier;Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphPattern; + public static fun graphQuantifier (JLjava/lang/Long;)Lorg/partiql/ast/v1/graph/GraphQuantifier; + public static fun graphSelectorAllShortest ()Lorg/partiql/ast/v1/graph/GraphSelector$AllShortest; + public static fun graphSelectorAny ()Lorg/partiql/ast/v1/graph/GraphSelector$Any; + public static fun graphSelectorAnyK (J)Lorg/partiql/ast/v1/graph/GraphSelector$AnyK; + public static fun graphSelectorAnyShortest ()Lorg/partiql/ast/v1/graph/GraphSelector$AnyShortest; + public static fun graphSelectorShortestK (J)Lorg/partiql/ast/v1/graph/GraphSelector$ShortestK; + public static fun graphSelectorShortestKGroup (J)Lorg/partiql/ast/v1/graph/GraphSelector$ShortestKGroup; + public static fun groupBy (Lorg/partiql/ast/v1/GroupByStrategy;Ljava/util/List;Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/GroupBy; + public static fun groupByKey (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/GroupBy$Key; + public static fun identifier (Ljava/lang/String;Z)Lorg/partiql/ast/v1/Identifier; + public static fun identifierChain (Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/IdentifierChain;)Lorg/partiql/ast/v1/IdentifierChain; + public static fun let (Ljava/util/List;)Lorg/partiql/ast/v1/Let; + public static fun letBinding (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/Let$Binding; + public static fun orderBy (Ljava/util/List;)Lorg/partiql/ast/v1/OrderBy; + public static fun query (Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/Query; + public static fun queryBodySFW (Lorg/partiql/ast/v1/Select;Lorg/partiql/ast/v1/Exclude;Lorg/partiql/ast/v1/From;Lorg/partiql/ast/v1/Let;Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/GroupBy;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/QueryBody$SFW; + public static fun queryBodySetOp (Lorg/partiql/ast/v1/SetOp;ZLorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/QueryBody$SetOp; + public static fun selectItemExpr (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/SelectItem$Expr; + public static fun selectItemStar (Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/SelectItem$Star; + public static fun selectList (Ljava/util/List;Lorg/partiql/ast/v1/SetQuantifier;)Lorg/partiql/ast/v1/SelectList; + public static fun selectPivot (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/SelectPivot; + public static fun selectStar (Lorg/partiql/ast/v1/SetQuantifier;)Lorg/partiql/ast/v1/SelectStar; + public static fun selectValue (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/SetQuantifier;)Lorg/partiql/ast/v1/SelectValue; + public static fun setOp (Lorg/partiql/ast/v1/SetOpType;Lorg/partiql/ast/v1/SetQuantifier;)Lorg/partiql/ast/v1/SetOp; + public static fun sort (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/Order;Lorg/partiql/ast/v1/Nulls;)Lorg/partiql/ast/v1/Sort; +} + public abstract class org/partiql/ast/v1/AstNode { public field tag Ljava/lang/String; public fun ()V @@ -5637,8 +5725,8 @@ public abstract interface class org/partiql/ast/v1/AstVisitor { public abstract fun visitQueryBodySetOp (Lorg/partiql/ast/v1/QueryBody$SetOp;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelect (Lorg/partiql/ast/v1/Select;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelectItem (Lorg/partiql/ast/v1/SelectItem;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitSelectItemAll (Lorg/partiql/ast/v1/SelectItem$Star;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelectItemExpr (Lorg/partiql/ast/v1/SelectItem$Expr;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitSelectItemStar (Lorg/partiql/ast/v1/SelectItem$Star;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelectList (Lorg/partiql/ast/v1/SelectList;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelectPivot (Lorg/partiql/ast/v1/SelectPivot;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSelectStar (Lorg/partiql/ast/v1/SelectStar;Ljava/lang/Object;)Ljava/lang/Object; @@ -7094,6 +7182,7 @@ public class org/partiql/ast/v1/graph/GraphLabel$Negation$Builder { } public class org/partiql/ast/v1/graph/GraphLabel$Wildcard : org/partiql/ast/v1/graph/GraphLabel { + public fun ()V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphLabel$Wildcard$Builder; public fun children ()Ljava/util/Collection; @@ -7202,9 +7291,9 @@ public class org/partiql/ast/v1/graph/GraphPattern$Builder { } public class org/partiql/ast/v1/graph/GraphQuantifier : org/partiql/ast/v1/AstNode { - public final field lower Ljava/lang/Long; + public final field lower J public final field upper Ljava/lang/Long; - public fun (Ljava/lang/Long;Ljava/lang/Long;)V + public fun (JLjava/lang/Long;)V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphQuantifier$Builder; public fun children ()Ljava/util/Collection; @@ -7212,7 +7301,7 @@ public class org/partiql/ast/v1/graph/GraphQuantifier : org/partiql/ast/v1/AstNo public class org/partiql/ast/v1/graph/GraphQuantifier$Builder { public fun build ()Lorg/partiql/ast/v1/graph/GraphQuantifier; - public fun lower (Ljava/lang/Long;)Lorg/partiql/ast/v1/graph/GraphQuantifier$Builder; + public fun lower (J)Lorg/partiql/ast/v1/graph/GraphQuantifier$Builder; public fun toString ()Ljava/lang/String; public fun upper (Ljava/lang/Long;)Lorg/partiql/ast/v1/graph/GraphQuantifier$Builder; } @@ -7235,6 +7324,7 @@ public abstract class org/partiql/ast/v1/graph/GraphSelector : org/partiql/ast/v } public class org/partiql/ast/v1/graph/GraphSelector$AllShortest : org/partiql/ast/v1/graph/GraphSelector { + public fun ()V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphSelector$AllShortest$Builder; public fun children ()Ljava/util/Collection; @@ -7246,6 +7336,7 @@ public class org/partiql/ast/v1/graph/GraphSelector$AllShortest$Builder { } public class org/partiql/ast/v1/graph/GraphSelector$Any : org/partiql/ast/v1/graph/GraphSelector { + public fun ()V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphSelector$Any$Builder; public fun children ()Ljava/util/Collection; @@ -7271,6 +7362,7 @@ public class org/partiql/ast/v1/graph/GraphSelector$AnyK$Builder { } public class org/partiql/ast/v1/graph/GraphSelector$AnyShortest : org/partiql/ast/v1/graph/GraphSelector { + public fun ()V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphSelector$AnyShortest$Builder; public fun children ()Ljava/util/Collection; diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java b/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java new file mode 100644 index 0000000000..5005a7c9b5 --- /dev/null +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java @@ -0,0 +1,481 @@ +package org.partiql.ast.v1; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.partiql.ast.v1.expr.Expr; +import org.partiql.ast.v1.expr.ExprAnd; +import org.partiql.ast.v1.expr.ExprArray; +import org.partiql.ast.v1.expr.ExprBag; +import org.partiql.ast.v1.expr.ExprBetween; +import org.partiql.ast.v1.expr.ExprCall; +import org.partiql.ast.v1.expr.ExprCase; +import org.partiql.ast.v1.expr.ExprCast; +import org.partiql.ast.v1.expr.ExprCoalesce; +import org.partiql.ast.v1.expr.ExprExtract; +import org.partiql.ast.v1.expr.ExprInCollection; +import org.partiql.ast.v1.expr.ExprIsType; +import org.partiql.ast.v1.expr.ExprLike; +import org.partiql.ast.v1.expr.ExprLit; +import org.partiql.ast.v1.expr.ExprMatch; +import org.partiql.ast.v1.expr.ExprNot; +import org.partiql.ast.v1.expr.ExprNullIf; +import org.partiql.ast.v1.expr.ExprOperator; +import org.partiql.ast.v1.expr.ExprOr; +import org.partiql.ast.v1.expr.ExprOverlay; +import org.partiql.ast.v1.expr.ExprParameter; +import org.partiql.ast.v1.expr.ExprPath; +import org.partiql.ast.v1.expr.ExprPosition; +import org.partiql.ast.v1.expr.ExprQuerySet; +import org.partiql.ast.v1.expr.ExprSessionAttribute; +import org.partiql.ast.v1.expr.ExprStruct; +import org.partiql.ast.v1.expr.ExprSubstring; +import org.partiql.ast.v1.expr.ExprTrim; +import org.partiql.ast.v1.expr.ExprValues; +import org.partiql.ast.v1.expr.ExprVarRef; +import org.partiql.ast.v1.expr.ExprVariant; +import org.partiql.ast.v1.expr.ExprWindow; +import org.partiql.ast.v1.expr.PathStep; +import org.partiql.ast.v1.expr.Scope; +import org.partiql.ast.v1.expr.SessionAttribute; +import org.partiql.ast.v1.expr.TrimSpec; +import org.partiql.ast.v1.expr.WindowFunction; +import org.partiql.ast.v1.graph.GraphDirection; +import org.partiql.ast.v1.graph.GraphLabel; +import org.partiql.ast.v1.graph.GraphMatch; +import org.partiql.ast.v1.graph.GraphPart; +import org.partiql.ast.v1.graph.GraphPattern; +import org.partiql.ast.v1.graph.GraphQuantifier; +import org.partiql.ast.v1.graph.GraphRestrictor; +import org.partiql.ast.v1.graph.GraphSelector; +import org.partiql.value.PartiQLValue; + +import java.util.List; +import java.util.Map; + +// TODO docs for all factory methods +public class Ast { + // Expr + @NotNull + public static ExprAnd exprAnd(Expr lhs, Expr rhs) { + return new ExprAnd(lhs, rhs); + } + + @NotNull + public static ExprArray exprArray(@NotNull List values) { + return new ExprArray(values); + } + + @NotNull + public static ExprBag exprBag(@NotNull List values) { + return new ExprBag(values); + } + + @NotNull + public static ExprBetween exprBetween(@NotNull Expr value, @NotNull Expr from, @NotNull Expr to, boolean not) { + return new ExprBetween(value, from, to, not); + } + + @NotNull + public static ExprCall exprCall(@NotNull IdentifierChain function, @NotNull List args, @Nullable SetQuantifier setq) { + return new ExprCall(function, args, setq); + } + + @NotNull + public static ExprCase exprCase(@Nullable Expr expr, @NotNull List branches, @Nullable Expr defaultExpr) { + return new ExprCase(expr, branches, defaultExpr); + } + + @NotNull + public static ExprCase.Branch exprCaseBranch(@NotNull Expr condition, @NotNull Expr expr) { + return new ExprCase.Branch(condition, expr); + } + + @NotNull + public static ExprCast exprCast(@NotNull Expr value, @NotNull DataType asType) { + return new ExprCast(value, asType); + } + + @NotNull + public static ExprCoalesce exprCoalesce(@NotNull List args) { + return new ExprCoalesce(args); + } + + @NotNull + public static ExprExtract exprExtract(@NotNull DatetimeField field, @NotNull Expr source) { + return new ExprExtract(field, source); + } + + @NotNull + public static ExprInCollection exprInCollection(@NotNull Expr lhs, @NotNull Expr rhs, boolean not) { + return new ExprInCollection(lhs, rhs, not); + } + + @NotNull + public static ExprIsType exprIsType(@NotNull Expr value, @NotNull DataType type, boolean not) { + return new ExprIsType(value, type, not); + } + + @NotNull + public static ExprLike exprLike(@NotNull Expr value, @NotNull Expr Pattern, @Nullable Expr escape, boolean not) { + return new ExprLike(value, Pattern, escape, not); + } + + // This representation will be changed in https://github.com/partiql/partiql-lang-kotlin/issues/1589 + @NotNull + public static ExprLit exprLit(@NotNull PartiQLValue value) { + return new ExprLit(value); + } + + @NotNull + public static ExprMatch exprMatch(@NotNull Expr expr, @NotNull GraphMatch pattern) { + return new ExprMatch(expr, pattern); + } + + @NotNull + public static ExprNot exprNot(@NotNull Expr value) { + return new ExprNot(value); + } + + @NotNull + public static ExprNullIf exprNullIf(@NotNull Expr v1, @NotNull Expr v2) { + return new ExprNullIf(v1, v2); + } + + @NotNull + public static ExprOperator exprOperator(@NotNull String symbol, @Nullable Expr lhs, @NotNull Expr rhs) { + return new ExprOperator(symbol, lhs, rhs); + } + + @NotNull + public static ExprOr exprOr(@NotNull Expr lhs, @NotNull Expr rhs) { + return new ExprOr(lhs, rhs); + } + + @NotNull + public static ExprOverlay exprOverlay(@NotNull Expr value, @NotNull Expr placing, @NotNull Expr from, @Nullable Expr forLength) { + return new ExprOverlay(value, placing, from, forLength); + } + + @NotNull + public static ExprParameter exprParameter(int index) { + return new ExprParameter(index); + } + + @NotNull + public static ExprPath exprPath(@NotNull Expr root, @Nullable PathStep next) { + return new ExprPath(root, next); + } + + @NotNull + public static ExprPosition exprPosition(@NotNull Expr lhs, @NotNull Expr rhs) { + return new ExprPosition(lhs, rhs); + } + + @NotNull + public static ExprQuerySet exprQuerySet(@NotNull QueryBody body, @Nullable OrderBy orderBy, @Nullable Expr limit, @Nullable Expr offset) { + return new ExprQuerySet(body, orderBy, limit, offset); + } + + @NotNull + public static ExprSessionAttribute exprSessionAttribute(@NotNull SessionAttribute sessionAttribute) { + return new ExprSessionAttribute(sessionAttribute); + } + + @NotNull + public static ExprStruct exprStruct(@NotNull List fields) { + return new ExprStruct(fields); + } + + @NotNull + public static ExprStruct.Field exprStructField(@NotNull Expr name, @NotNull Expr value) { + return new ExprStruct.Field(name, value); + } + + @NotNull + public static ExprSubstring exprSubstring(@NotNull Expr value, @Nullable Expr start, @Nullable Expr length) { + return new ExprSubstring(value, start, length); + } + + @NotNull + public static ExprTrim exprTrim(@NotNull Expr Value, @Nullable Expr chars, @Nullable TrimSpec trimSpec) { + return new ExprTrim(Value, chars, trimSpec); + } + + @NotNull + public static ExprValues exprValues(@NotNull List rows) { + return new ExprValues(rows); + } + + @NotNull + public static ExprValues.Row exprValuesRow(@NotNull List values) { + return new ExprValues.Row(values); + } + + @NotNull + public static ExprVariant exprVariant(@NotNull String value, @NotNull String encoding) { + return new ExprVariant(value, encoding); + } + + @NotNull + public static ExprVarRef exprVarRef(@NotNull IdentifierChain identifierChain, @NotNull Scope scope) { + return new ExprVarRef(identifierChain, scope); + } + + @NotNull + public static ExprWindow exprWindow(@NotNull WindowFunction windowFunction, @NotNull Expr exression, @Nullable Expr offset, @Nullable Expr defaultValue, @NotNull ExprWindow.Over over) { + return new ExprWindow(windowFunction, exression, offset, defaultValue, over); + } + + @NotNull + public static ExprWindow.Over exprWindowOver(@Nullable List partitions, @Nullable List sorts) { + return new ExprWindow.Over(partitions, sorts); + } + + @NotNull + public static PathStep.Field exprPathStepField(@NotNull Identifier value, @Nullable PathStep next) { + return new PathStep.Field(value, next); + } + + @NotNull + public static PathStep.Element exprPathStepElement(@NotNull Expr element, @Nullable PathStep next) { + return new PathStep.Element(element, next); + } + + @NotNull + public static PathStep.AllElements exprPathStepAllElements(@Nullable PathStep next) { + return new PathStep.AllElements(next); + } + + @NotNull + public static PathStep.AllFields exprPathStepAllFields(@Nullable PathStep next) { + return new PathStep.AllFields(next); + } + + // Graph + @NotNull + public static GraphLabel.Name graphLabelName(@NotNull String name) { + return new GraphLabel.Name(name); + } + + @NotNull + public static GraphLabel.Wildcard graphLabelWildcard() { + return new GraphLabel.Wildcard(); + } + + @NotNull + public static GraphLabel.Negation graphLabelNegation(@NotNull GraphLabel arg) { + return new GraphLabel.Negation(arg); + } + + @NotNull + public static GraphLabel.Conj graphLabelConj(@NotNull List args) { + return new GraphLabel.Conj(args); + } + + @NotNull + public static GraphLabel.Disj graphLabelDisj(@NotNull List args) { + return new GraphLabel.Disj(args); + } + + @NotNull + public static GraphMatch graphMatch(@NotNull List patterns, @Nullable GraphSelector selector) { + return new GraphMatch(patterns, selector); + } + + @NotNull + public static GraphPart.Node graphMatchNode(@Nullable Expr prefilter, @Nullable String variable, @Nullable GraphLabel label) { + return new GraphPart.Node(prefilter, variable, label); + } + + @NotNull + public static GraphPart.Edge graphMatchEdge(@NotNull GraphDirection direction, @Nullable GraphQuantifier quantifier, @Nullable Expr prefilter, @Nullable String variable, @Nullable GraphLabel label) { + return new GraphPart.Edge(direction, quantifier, prefilter, variable, label); + } + + @NotNull + public static GraphPart.Pattern graphMatchPattern(@NotNull GraphPattern pattern) { + return new GraphPart.Pattern(pattern); + } + + @NotNull + public static GraphPattern graphPattern(@Nullable GraphRestrictor restrictor, @Nullable Expr prefilter, @Nullable String variable, @Nullable GraphQuantifier quantifier, @NotNull List parts) { + return new GraphPattern(restrictor, prefilter, variable, quantifier, parts); + } + + @NotNull + public static GraphQuantifier graphQuantifier(long lower, @Nullable Long upper) { + return new GraphQuantifier(lower, upper); + } + + @NotNull + public static GraphSelector.AnyShortest graphSelectorAnyShortest() { + return new GraphSelector.AnyShortest(); + } + + @NotNull + public static GraphSelector.AllShortest graphSelectorAllShortest() { + return new GraphSelector.AllShortest(); + } + + @NotNull + public static GraphSelector.Any graphSelectorAny() { + return new GraphSelector.Any(); + } + + @NotNull + public static GraphSelector.AnyK graphSelectorAnyK(long k) { + return new GraphSelector.AnyK(k); + } + + @NotNull + public static GraphSelector.ShortestK graphSelectorShortestK(long k) { + return new GraphSelector.ShortestK(k); + } + + @NotNull + public static GraphSelector.ShortestKGroup graphSelectorShortestKGroup(long k) { + return new GraphSelector.ShortestKGroup(k); + } + + // Other + @NotNull + public static Exclude exclude(@NotNull List excludePaths) { + return new Exclude(excludePaths); + } + + @NotNull + public static ExcludePath excludePath(@NotNull ExprVarRef varRef, @NotNull List excludeSteps) { + return new ExcludePath(varRef, excludeSteps); + } + + @NotNull + public static ExcludeStep.StructField excludeStepStructField(@NotNull Identifier symbol) { + return new ExcludeStep.StructField(symbol); + } + + @NotNull + public static ExcludeStep.CollIndex excludeStepCollIndex(int index) { + return new ExcludeStep.CollIndex(index); + } + + @NotNull + public static ExcludeStep.StructWildcard excludeStepStructWildcard() { + return new ExcludeStep.StructWildcard(); + } + + @NotNull + public static ExcludeStep.CollWildcard excludeStepCollWildcard() { + return new ExcludeStep.CollWildcard(); + } + + // This representation will be changed in https://github.com/partiql/partiql-lang-kotlin/issues/1589 + @NotNull + public static Explain explain(@NotNull Map options, @NotNull Statement statement) { + return new Explain(options, statement); + } + + @NotNull + public static From from(@NotNull List tableRefs) { + return new From(tableRefs); + } + + @NotNull + public static FromExpr fromExpr(@NotNull Expr expr, @NotNull FromType fromType, @Nullable Identifier asAlias, @Nullable Identifier atAlias) { + return new FromExpr(expr, fromType, asAlias, atAlias); + } + + @NotNull + public static FromJoin fromJoin(@NotNull From lhs, @NotNull From rhs, @Nullable JoinType joinType, @Nullable Expr condition) { + return new FromJoin(lhs, rhs, joinType, condition); + } + + @NotNull + public static GroupBy groupBy(@NotNull GroupByStrategy strategy, @NotNull List keys, @Nullable Identifier asAlias) { + return new GroupBy(strategy, keys, asAlias); + } + + @NotNull + public static GroupBy.Key groupByKey(@NotNull Expr expr, @Nullable Identifier asAlias) { + return new GroupBy.Key(expr, asAlias); + } + + @NotNull + public static Identifier identifier(@NotNull String symbol, boolean isDelimited) { + return new Identifier(symbol, isDelimited); + } + + @NotNull + public static IdentifierChain identifierChain(@NotNull Identifier root, @Nullable IdentifierChain next) { + return new IdentifierChain(root, next); + } + + @NotNull + public static Let let(@NotNull List bindings) { + return new Let(bindings); + } + + @NotNull + public static Let.Binding letBinding(@NotNull Expr expr, @NotNull Identifier asAlias) { + return new Let.Binding(expr, asAlias); + } + + @NotNull + public static OrderBy orderBy(@NotNull List sorts) { + return new OrderBy(sorts); + } + + @NotNull + public static Query query(@NotNull Expr expr) { + return new Query(expr); + } + + @NotNull + public static QueryBody.SFW queryBodySFW(@NotNull Select select, @Nullable Exclude exclude, @NotNull From from, @Nullable Let let, @Nullable Expr where, @Nullable GroupBy groupBy, @Nullable Expr having) { + return new QueryBody.SFW(select, exclude, from, let, where, groupBy, having); + } + + @NotNull + public static QueryBody.SetOp queryBodySetOp(@NotNull org.partiql.ast.v1.SetOp type, boolean isOuter, @NotNull Expr lhs, @NotNull Expr rhs) { + return new QueryBody.SetOp(type, isOuter, lhs, rhs); + } + + @NotNull + public static SelectItem.Star selectItemStar(@NotNull Expr expr) { + return new SelectItem.Star(expr); + } + + @NotNull + public static SelectItem.Expr selectItemExpr(@NotNull Expr expr, @Nullable Identifier asAlias) { + return new SelectItem.Expr(expr, asAlias); + } + + @NotNull + public static SelectList selectList(@NotNull List items, @Nullable SetQuantifier setq) { + return new SelectList(items, setq); + } + + @NotNull + public static SelectPivot selectPivot(@NotNull Expr key, @NotNull Expr value) { + return new SelectPivot(key, value); + } + + @NotNull + public static SelectStar selectStar(@Nullable SetQuantifier setq) { + return new SelectStar(setq); + } + + @NotNull + public static SelectValue selectValue(@NotNull Expr constructor, @Nullable SetQuantifier setq) { + return new SelectValue(constructor, setq); + } + + @NotNull + public static SetOp setOp(@NotNull SetOpType setOpType, @Nullable SetQuantifier setq) { + return new SetOp(setOpType, setq); + } + + @NotNull + public static Sort sort(@NotNull Expr expr, @Nullable Order order, @Nullable Nulls nulls) { + return new Sort(expr, order, nulls); + } +} diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java b/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java index 5848612d65..6ac7c5f851 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java @@ -149,7 +149,7 @@ public interface AstVisitor { R visitSelectItem(SelectItem node, C ctx); - R visitSelectItemAll(SelectItem.Star node, C ctx); + R visitSelectItemStar(SelectItem.Star node, C ctx); R visitSelectItemExpr(SelectItem.Expr node, C ctx); diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/QueryBody.java b/partiql-ast/src/main/java/org/partiql/ast/v1/QueryBody.java index 4e2906e1b0..da03a2104c 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/QueryBody.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/QueryBody.java @@ -78,11 +78,11 @@ public static class SetOp extends QueryBody { public Expr rhs; public SetOp(@NotNull org.partiql.ast.v1.SetOp type, boolean isOuter, @NotNull Expr lhs, @NotNull Expr rhs) { - this.type = type; - this.isOuter = isOuter; - this.lhs = lhs; - this.rhs = rhs; - } + this.type = type; + this.isOuter = isOuter; + this.lhs = lhs; + this.rhs = rhs; + } @NotNull @Override diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/SelectItem.java b/partiql-ast/src/main/java/org/partiql/ast/v1/SelectItem.java index 6fad733fa0..fcdca90238 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/SelectItem.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/SelectItem.java @@ -15,7 +15,7 @@ public abstract class SelectItem extends AstNode { @Override public R accept(@NotNull AstVisitor visitor, C ctx) { if (this instanceof Star) { - return visitor.visitSelectItemAll((Star) this, ctx); + return visitor.visitSelectItemStar((Star) this, ctx); } else if (this instanceof Expr) { return visitor.visitSelectItemExpr((Expr) this, ctx); } else { @@ -45,7 +45,7 @@ public Collection children() { @Override public R accept(@NotNull AstVisitor visitor, C ctx) { - return visitor.visitSelectItemAll(this, ctx); + return visitor.visitSelectItemStar(this, ctx); } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java index bdd66fe3fc..9d513b9c75 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java @@ -59,6 +59,8 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { */ @Builder(builderClassName = "Builder") public static class Wildcard extends GraphLabel { + public Wildcard() {} + @Override @NotNull public Collection children() { diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphQuantifier.java b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphQuantifier.java index 2028be86a6..15fc42590b 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphQuantifier.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphQuantifier.java @@ -14,13 +14,12 @@ */ @Builder(builderClassName = "Builder") public class GraphQuantifier extends AstNode { - @NotNull - public final Long lower; + public final long lower; @Nullable public final Long upper; - public GraphQuantifier(@NotNull Long lower, @Nullable Long upper) { + public GraphQuantifier(long lower, @Nullable Long upper) { this.lower = lower; this.upper = upper; } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphSelector.java b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphSelector.java index e5e1a68479..85610eed63 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphSelector.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphSelector.java @@ -36,6 +36,8 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { */ @Builder(builderClassName = "Builder") public static class AnyShortest extends GraphSelector { + public AnyShortest() {} + @Override @NotNull public Collection children() { @@ -53,6 +55,8 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { */ @Builder(builderClassName = "Builder") public static class AllShortest extends GraphSelector { + public AllShortest() {} + @Override @NotNull public Collection children() { @@ -70,6 +74,8 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { */ @Builder(builderClassName = "Builder") public static class Any extends GraphSelector { + public Any() {} + @Override @NotNull public Collection children() { From 3dce47e79dff82ba9e710334e257b1bd497e447e Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Fri, 18 Oct 2024 12:11:04 -0700 Subject: [PATCH 2/2] Adjust GraphLabel Conj/Disj --- partiql-ast/api/partiql-ast.api | 20 ++++++++----- .../src/main/java/org/partiql/ast/v1/Ast.java | 8 ++--- .../org/partiql/ast/v1/graph/GraphLabel.java | 30 ++++++++++++++----- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index d6e8bcde7a..602d07ef90 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -5594,8 +5594,8 @@ public class org/partiql/ast/v1/Ast { public static fun from (Ljava/util/List;)Lorg/partiql/ast/v1/From; public static fun fromExpr (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/FromType;Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/Identifier;)Lorg/partiql/ast/v1/FromExpr; public static fun fromJoin (Lorg/partiql/ast/v1/From;Lorg/partiql/ast/v1/From;Lorg/partiql/ast/v1/JoinType;Lorg/partiql/ast/v1/expr/Expr;)Lorg/partiql/ast/v1/FromJoin; - public static fun graphLabelConj (Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphLabel$Conj; - public static fun graphLabelDisj (Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphLabel$Disj; + public static fun graphLabelConj (Lorg/partiql/ast/v1/graph/GraphLabel;Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Conj; + public static fun graphLabelDisj (Lorg/partiql/ast/v1/graph/GraphLabel;Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Disj; public static fun graphLabelName (Ljava/lang/String;)Lorg/partiql/ast/v1/graph/GraphLabel$Name; public static fun graphLabelNegation (Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Negation; public static fun graphLabelWildcard ()Lorg/partiql/ast/v1/graph/GraphLabel$Wildcard; @@ -7126,30 +7126,34 @@ public abstract class org/partiql/ast/v1/graph/GraphLabel : org/partiql/ast/v1/A } public class org/partiql/ast/v1/graph/GraphLabel$Conj : org/partiql/ast/v1/graph/GraphLabel { - public final field args Ljava/util/List; - public fun (Ljava/util/List;)V + public final field lhs Lorg/partiql/ast/v1/graph/GraphLabel; + public final field rhs Lorg/partiql/ast/v1/graph/GraphLabel; + public fun (Lorg/partiql/ast/v1/graph/GraphLabel;Lorg/partiql/ast/v1/graph/GraphLabel;)V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphLabel$Conj$Builder; public fun children ()Ljava/util/Collection; } public class org/partiql/ast/v1/graph/GraphLabel$Conj$Builder { - public fun args (Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphLabel$Conj$Builder; public fun build ()Lorg/partiql/ast/v1/graph/GraphLabel$Conj; + public fun lhs (Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Conj$Builder; + public fun rhs (Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Conj$Builder; public fun toString ()Ljava/lang/String; } public class org/partiql/ast/v1/graph/GraphLabel$Disj : org/partiql/ast/v1/graph/GraphLabel { - public final field args Ljava/util/List; - public fun (Ljava/util/List;)V + public final field lhs Lorg/partiql/ast/v1/graph/GraphLabel; + public final field rhs Lorg/partiql/ast/v1/graph/GraphLabel; + public fun (Lorg/partiql/ast/v1/graph/GraphLabel;Lorg/partiql/ast/v1/graph/GraphLabel;)V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/v1/graph/GraphLabel$Disj$Builder; public fun children ()Ljava/util/Collection; } public class org/partiql/ast/v1/graph/GraphLabel$Disj$Builder { - public fun args (Ljava/util/List;)Lorg/partiql/ast/v1/graph/GraphLabel$Disj$Builder; public fun build ()Lorg/partiql/ast/v1/graph/GraphLabel$Disj; + public fun lhs (Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Disj$Builder; + public fun rhs (Lorg/partiql/ast/v1/graph/GraphLabel;)Lorg/partiql/ast/v1/graph/GraphLabel$Disj$Builder; public fun toString ()Ljava/lang/String; } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java b/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java index 5005a7c9b5..9d1299d8ab 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/Ast.java @@ -268,13 +268,13 @@ public static GraphLabel.Negation graphLabelNegation(@NotNull GraphLabel arg) { } @NotNull - public static GraphLabel.Conj graphLabelConj(@NotNull List args) { - return new GraphLabel.Conj(args); + public static GraphLabel.Conj graphLabelConj(@NotNull GraphLabel lhs, @NotNull GraphLabel rhs) { + return new GraphLabel.Conj(lhs, rhs); } @NotNull - public static GraphLabel.Disj graphLabelDisj(@NotNull List args) { - return new GraphLabel.Disj(args); + public static GraphLabel.Disj graphLabelDisj(@NotNull GraphLabel lhs, @NotNull GraphLabel rhs) { + return new GraphLabel.Disj(lhs, rhs); } @NotNull diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java index 9d513b9c75..a61aa72ab7 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphLabel.java @@ -105,16 +105,23 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { @Builder(builderClassName = "Builder") public static class Conj extends GraphLabel { @NotNull - public final List args; + public final GraphLabel lhs; - public Conj(@NotNull List args) { - this.args = args; + @NotNull + public final GraphLabel rhs; + + public Conj(@NotNull GraphLabel lhs, @NotNull GraphLabel rhs) { + this.lhs = lhs; + this.rhs = rhs; } @Override @NotNull public Collection children() { - return new ArrayList<>(args); + List kids = new ArrayList<>(); + kids.add(lhs); + kids.add(rhs); + return kids; } @Override @@ -129,16 +136,23 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { @Builder(builderClassName = "Builder") public static class Disj extends GraphLabel { @NotNull - public final List args; + public final GraphLabel lhs; - public Disj(@NotNull List args) { - this.args = args; + @NotNull + public final GraphLabel rhs; + + public Disj(@NotNull GraphLabel lhs, @NotNull GraphLabel rhs) { + this.lhs = lhs; + this.rhs = rhs; } @Override @NotNull public Collection children() { - return new ArrayList<>(args); + List kids = new ArrayList<>(); + kids.add(lhs); + kids.add(rhs); + return kids; } @Override