From 6834370c9293e0b63348a5342e016c3220ee6248 Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Tue, 10 Dec 2024 13:54:15 -0800 Subject: [PATCH] Add @JvmOverloads and necessary hand-written factory methods; make window over fields nonnull --- partiql-ast/api/partiql-ast.api | 64 ++++++++++++++++- .../java/org/partiql/ast/expr/ExprWindow.java | 14 ++-- .../src/main/kotlin/org/partiql/ast/Ast.kt | 70 ++++++++++++++++++- .../kotlin/org/partiql/ast/AstRewriter.kt | 4 +- .../parser/internal/PartiQLParserDefault.kt | 7 +- 5 files changed, 139 insertions(+), 20 deletions(-) diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index 74e0eae17..487b30390 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -1,23 +1,31 @@ public final class org/partiql/ast/Ast { public static final field INSTANCE Lorg/partiql/ast/Ast; public static final fun columnConstraintCheck (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/ddl/AttributeConstraint$Check; + public static final fun columnConstraintCheck (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/ddl/AttributeConstraint$Check; public static synthetic fun columnConstraintCheck$default (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/ddl/AttributeConstraint$Check; public static final fun columnConstraintNullable (Lorg/partiql/ast/IdentifierChain;Z)Lorg/partiql/ast/ddl/AttributeConstraint$Null; + public static final fun columnConstraintNullable (Z)Lorg/partiql/ast/ddl/AttributeConstraint$Null; public static synthetic fun columnConstraintNullable$default (Lorg/partiql/ast/IdentifierChain;ZILjava/lang/Object;)Lorg/partiql/ast/ddl/AttributeConstraint$Null; public static final fun columnConstraintUnique (Lorg/partiql/ast/IdentifierChain;Z)Lorg/partiql/ast/ddl/AttributeConstraint$Unique; + public static final fun columnConstraintUnique (Z)Lorg/partiql/ast/ddl/AttributeConstraint$Unique; public static synthetic fun columnConstraintUnique$default (Lorg/partiql/ast/IdentifierChain;ZILjava/lang/Object;)Lorg/partiql/ast/ddl/AttributeConstraint$Unique; + public static final fun columnDefinition (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/DataType;ZLjava/util/List;)Lorg/partiql/ast/ddl/ColumnDefinition; public static final fun columnDefinition (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/DataType;ZLjava/util/List;Ljava/lang/String;)Lorg/partiql/ast/ddl/ColumnDefinition; public static synthetic fun columnDefinition$default (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/DataType;ZLjava/util/List;Ljava/lang/String;ILjava/lang/Object;)Lorg/partiql/ast/ddl/ColumnDefinition; public static final fun conflictTargetConstraint (Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/dml/ConflictTarget$Constraint; public static final fun conflictTargetIndex (Ljava/util/List;)Lorg/partiql/ast/dml/ConflictTarget$Index; + public static final fun createTable (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Ljava/util/List;Ljava/util/List;)Lorg/partiql/ast/ddl/CreateTable; public static final fun createTable (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Ljava/util/List;Lorg/partiql/ast/ddl/PartitionBy;Ljava/util/List;)Lorg/partiql/ast/ddl/CreateTable; public static synthetic fun createTable$default (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Ljava/util/List;Lorg/partiql/ast/ddl/PartitionBy;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/ast/ddl/CreateTable; + public static final fun delete (Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/dml/Delete; public static final fun delete (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/Delete; public static synthetic fun delete$default (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/dml/Delete; public static final fun doNothing ()Lorg/partiql/ast/dml/ConflictAction$DoNothing; + public static final fun doReplace (Lorg/partiql/ast/dml/DoReplaceAction;)Lorg/partiql/ast/dml/ConflictAction$DoReplace; public static final fun doReplace (Lorg/partiql/ast/dml/DoReplaceAction;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/ConflictAction$DoReplace; public static synthetic fun doReplace$default (Lorg/partiql/ast/dml/DoReplaceAction;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/dml/ConflictAction$DoReplace; public static final fun doReplaceActionExcluded ()Lorg/partiql/ast/dml/DoReplaceAction$Excluded; + public static final fun doUpdate (Lorg/partiql/ast/dml/DoUpdateAction;)Lorg/partiql/ast/dml/ConflictAction$DoUpdate; public static final fun doUpdate (Lorg/partiql/ast/dml/DoUpdateAction;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/ConflictAction$DoUpdate; public static synthetic fun doUpdate$default (Lorg/partiql/ast/dml/DoUpdateAction;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/dml/ConflictAction$DoUpdate; public static final fun doUpdateActionExcluded ()Lorg/partiql/ast/dml/DoUpdateAction$Excluded; @@ -32,8 +40,11 @@ public final class org/partiql/ast/Ast { public static final fun exprArray (Ljava/util/List;)Lorg/partiql/ast/expr/ExprArray; public static final fun exprBag (Ljava/util/List;)Lorg/partiql/ast/expr/ExprBag; public static final fun exprBetween (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Z)Lorg/partiql/ast/expr/ExprBetween; + public static final fun exprCall (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;)Lorg/partiql/ast/expr/ExprCall; public static final fun exprCall (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/expr/ExprCall; public static synthetic fun exprCall$default (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Lorg/partiql/ast/SetQuantifier;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprCall; + public static final fun exprCase (Ljava/util/List;)Lorg/partiql/ast/expr/ExprCase; + public static final fun exprCase (Lorg/partiql/ast/expr/Expr;Ljava/util/List;)Lorg/partiql/ast/expr/ExprCase; public static final fun exprCase (Lorg/partiql/ast/expr/Expr;Ljava/util/List;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprCase; public static synthetic fun exprCase$default (Lorg/partiql/ast/expr/Expr;Ljava/util/List;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprCase; public static final fun exprCaseBranch (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprCase$Branch; @@ -43,28 +54,37 @@ public final class org/partiql/ast/Ast { public static final fun exprInCollection (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Z)Lorg/partiql/ast/expr/ExprInCollection; public static final fun exprIsType (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/DataType;Z)Lorg/partiql/ast/expr/ExprIsType; public static final fun exprLike (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Z)Lorg/partiql/ast/expr/ExprLike; + public static final fun exprLike (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Z)Lorg/partiql/ast/expr/ExprLike; public static synthetic fun exprLike$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;ZILjava/lang/Object;)Lorg/partiql/ast/expr/ExprLike; public static final fun exprLit (Lorg/partiql/ast/Literal;)Lorg/partiql/ast/expr/ExprLit; public static final fun exprMatch (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/graph/GraphMatch;)Lorg/partiql/ast/expr/ExprMatch; public static final fun exprNot (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprNot; public static final fun exprNullIf (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprNullIf; + public static final fun exprOperator (Ljava/lang/String;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprOperator; public static final fun exprOperator (Ljava/lang/String;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprOperator; public static synthetic fun exprOperator$default (Ljava/lang/String;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprOperator; public static final fun exprOr (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprOr; + public static final fun exprOverlay (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprOverlay; public static final fun exprOverlay (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprOverlay; public static synthetic fun exprOverlay$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprOverlay; public static final fun exprParameter (I)Lorg/partiql/ast/expr/ExprParameter; + public static final fun exprPath (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprPath; public static final fun exprPath (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/PathStep;)Lorg/partiql/ast/expr/ExprPath; public static synthetic fun exprPath$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/PathStep;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprPath; + public static final fun exprPathStepAllElements ()Lorg/partiql/ast/expr/PathStep$AllElements; public static final fun exprPathStepAllElements (Lorg/partiql/ast/expr/PathStep;)Lorg/partiql/ast/expr/PathStep$AllElements; public static synthetic fun exprPathStepAllElements$default (Lorg/partiql/ast/expr/PathStep;ILjava/lang/Object;)Lorg/partiql/ast/expr/PathStep$AllElements; + public static final fun exprPathStepAllFields ()Lorg/partiql/ast/expr/PathStep$AllFields; public static final fun exprPathStepAllFields (Lorg/partiql/ast/expr/PathStep;)Lorg/partiql/ast/expr/PathStep$AllFields; public static synthetic fun exprPathStepAllFields$default (Lorg/partiql/ast/expr/PathStep;ILjava/lang/Object;)Lorg/partiql/ast/expr/PathStep$AllFields; + public static final fun exprPathStepElement (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/PathStep$Element; public static final fun exprPathStepElement (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/PathStep;)Lorg/partiql/ast/expr/PathStep$Element; public static synthetic fun exprPathStepElement$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/PathStep;ILjava/lang/Object;)Lorg/partiql/ast/expr/PathStep$Element; + public static final fun exprPathStepField (Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/expr/PathStep$Field; public static final fun exprPathStepField (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/expr/PathStep;)Lorg/partiql/ast/expr/PathStep$Field; public static synthetic fun exprPathStepField$default (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/expr/PathStep;ILjava/lang/Object;)Lorg/partiql/ast/expr/PathStep$Field; public static final fun exprPosition (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprPosition; + public static final fun exprQuerySet (Lorg/partiql/ast/QueryBody;)Lorg/partiql/ast/expr/ExprQuerySet; public static final fun exprQuerySet (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprQuerySet; public static synthetic fun exprQuerySet$default (Lorg/partiql/ast/QueryBody;Lorg/partiql/ast/OrderBy;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprQuerySet; public static final fun exprRowValue (Ljava/util/List;)Lorg/partiql/ast/expr/ExprRowValue; @@ -72,20 +92,29 @@ public final class org/partiql/ast/Ast { public static final fun exprSessionAttribute (Lorg/partiql/ast/expr/SessionAttribute;)Lorg/partiql/ast/expr/ExprSessionAttribute; public static final fun exprStruct (Ljava/util/List;)Lorg/partiql/ast/expr/ExprStruct; public static final fun exprStructField (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprStruct$Field; + public static final fun exprSubstring (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprSubstring; + public static final fun exprSubstring (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprSubstring; public static final fun exprSubstring (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprSubstring; public static synthetic fun exprSubstring$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprSubstring; + public static final fun exprTrim (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprTrim; + public static final fun exprTrim (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/expr/ExprTrim; public static final fun exprTrim (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/TrimSpec;)Lorg/partiql/ast/expr/ExprTrim; public static synthetic fun exprTrim$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/TrimSpec;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprTrim; public static final fun exprValues (Ljava/util/List;)Lorg/partiql/ast/expr/ExprValues; public static final fun exprVarRef (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/expr/Scope;)Lorg/partiql/ast/expr/ExprVarRef; public static final fun exprVariant (Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/ast/expr/ExprVariant; public static final fun exprWindow (Lorg/partiql/ast/expr/WindowFunction;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/ExprWindow$Over;)Lorg/partiql/ast/expr/ExprWindow; + public static final fun exprWindow (Lorg/partiql/ast/expr/WindowFunction;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/ExprWindow$Over;)Lorg/partiql/ast/expr/ExprWindow; + public static final fun exprWindow (Lorg/partiql/ast/expr/WindowFunction;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/ExprWindow$Over;)Lorg/partiql/ast/expr/ExprWindow; public static synthetic fun exprWindow$default (Lorg/partiql/ast/expr/WindowFunction;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/ExprWindow$Over;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprWindow; public static final fun exprWindowOver (Ljava/util/List;Ljava/util/List;)Lorg/partiql/ast/expr/ExprWindow$Over; - public static synthetic fun exprWindowOver$default (Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/ast/expr/ExprWindow$Over; public static final fun from (Ljava/util/List;)Lorg/partiql/ast/From; + public static final fun fromExpr (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/FromType;)Lorg/partiql/ast/FromExpr; + public static final fun fromExpr (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/FromType;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/FromExpr; public static final fun fromExpr (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/FromType;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/FromExpr; public static synthetic fun fromExpr$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/FromType;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/Identifier;ILjava/lang/Object;)Lorg/partiql/ast/FromExpr; + public static final fun fromJoin (Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/FromTableRef;)Lorg/partiql/ast/FromJoin; + public static final fun fromJoin (Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/JoinType;)Lorg/partiql/ast/FromJoin; public static final fun fromJoin (Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/JoinType;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/FromJoin; public static synthetic fun fromJoin$default (Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/FromTableRef;Lorg/partiql/ast/JoinType;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/FromJoin; public static final fun graphLabelConj (Lorg/partiql/ast/graph/GraphLabel;Lorg/partiql/ast/graph/GraphLabel;)Lorg/partiql/ast/graph/GraphLabel$Conj; @@ -93,15 +122,28 @@ public final class org/partiql/ast/Ast { public static final fun graphLabelName (Ljava/lang/String;)Lorg/partiql/ast/graph/GraphLabel$Name; public static final fun graphLabelNegation (Lorg/partiql/ast/graph/GraphLabel;)Lorg/partiql/ast/graph/GraphLabel$Negation; public static final fun graphLabelWildcard ()Lorg/partiql/ast/graph/GraphLabel$Wildcard; + public static final fun graphMatch (Ljava/util/List;)Lorg/partiql/ast/graph/GraphMatch; public static final fun graphMatch (Ljava/util/List;Lorg/partiql/ast/graph/GraphSelector;)Lorg/partiql/ast/graph/GraphMatch; public static synthetic fun graphMatch$default (Ljava/util/List;Lorg/partiql/ast/graph/GraphSelector;ILjava/lang/Object;)Lorg/partiql/ast/graph/GraphMatch; + public static final fun graphMatchEdge (Lorg/partiql/ast/graph/GraphDirection;)Lorg/partiql/ast/graph/GraphPart$Edge; + public static final fun graphMatchEdge (Lorg/partiql/ast/graph/GraphDirection;Lorg/partiql/ast/graph/GraphQuantifier;)Lorg/partiql/ast/graph/GraphPart$Edge; + public static final fun graphMatchEdge (Lorg/partiql/ast/graph/GraphDirection;Lorg/partiql/ast/graph/GraphQuantifier;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/graph/GraphPart$Edge; + public static final fun graphMatchEdge (Lorg/partiql/ast/graph/GraphDirection;Lorg/partiql/ast/graph/GraphQuantifier;Lorg/partiql/ast/expr/Expr;Ljava/lang/String;)Lorg/partiql/ast/graph/GraphPart$Edge; public static final fun graphMatchEdge (Lorg/partiql/ast/graph/GraphDirection;Lorg/partiql/ast/graph/GraphQuantifier;Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/graph/GraphLabel;)Lorg/partiql/ast/graph/GraphPart$Edge; public static synthetic fun graphMatchEdge$default (Lorg/partiql/ast/graph/GraphDirection;Lorg/partiql/ast/graph/GraphQuantifier;Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/graph/GraphLabel;ILjava/lang/Object;)Lorg/partiql/ast/graph/GraphPart$Edge; + public static final fun graphMatchNode ()Lorg/partiql/ast/graph/GraphPart$Node; + public static final fun graphMatchNode (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/graph/GraphPart$Node; + public static final fun graphMatchNode (Lorg/partiql/ast/expr/Expr;Ljava/lang/String;)Lorg/partiql/ast/graph/GraphPart$Node; public static final fun graphMatchNode (Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/graph/GraphLabel;)Lorg/partiql/ast/graph/GraphPart$Node; public static synthetic fun graphMatchNode$default (Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/graph/GraphLabel;ILjava/lang/Object;)Lorg/partiql/ast/graph/GraphPart$Node; public static final fun graphMatchPattern (Lorg/partiql/ast/graph/GraphPattern;)Lorg/partiql/ast/graph/GraphPart$Pattern; + public static final fun graphPattern (Ljava/util/List;)Lorg/partiql/ast/graph/GraphPattern; + public static final fun graphPattern (Lorg/partiql/ast/graph/GraphRestrictor;Ljava/util/List;)Lorg/partiql/ast/graph/GraphPattern; + public static final fun graphPattern (Lorg/partiql/ast/graph/GraphRestrictor;Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Ljava/util/List;)Lorg/partiql/ast/graph/GraphPattern; public static final fun graphPattern (Lorg/partiql/ast/graph/GraphRestrictor;Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/graph/GraphQuantifier;Ljava/util/List;)Lorg/partiql/ast/graph/GraphPattern; + public static final fun graphPattern (Lorg/partiql/ast/graph/GraphRestrictor;Lorg/partiql/ast/expr/Expr;Ljava/util/List;)Lorg/partiql/ast/graph/GraphPattern; public static synthetic fun graphPattern$default (Lorg/partiql/ast/graph/GraphRestrictor;Lorg/partiql/ast/expr/Expr;Ljava/lang/String;Lorg/partiql/ast/graph/GraphQuantifier;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/ast/graph/GraphPattern; + public static final fun graphQuantifier (J)Lorg/partiql/ast/graph/GraphQuantifier; public static final fun graphQuantifier (JLjava/lang/Long;)Lorg/partiql/ast/graph/GraphQuantifier; public static synthetic fun graphQuantifier$default (JLjava/lang/Long;ILjava/lang/Object;)Lorg/partiql/ast/graph/GraphQuantifier; public static final fun graphSelectorAllShortest ()Lorg/partiql/ast/graph/GraphSelector$AllShortest; @@ -110,48 +152,67 @@ public final class org/partiql/ast/Ast { public static final fun graphSelectorAnyShortest ()Lorg/partiql/ast/graph/GraphSelector$AnyShortest; public static final fun graphSelectorShortestK (J)Lorg/partiql/ast/graph/GraphSelector$ShortestK; public static final fun graphSelectorShortestKGroup (J)Lorg/partiql/ast/graph/GraphSelector$ShortestKGroup; + public static final fun groupBy (Lorg/partiql/ast/GroupByStrategy;Ljava/util/List;)Lorg/partiql/ast/GroupBy; public static final fun groupBy (Lorg/partiql/ast/GroupByStrategy;Ljava/util/List;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/GroupBy; public static synthetic fun groupBy$default (Lorg/partiql/ast/GroupByStrategy;Ljava/util/List;Lorg/partiql/ast/Identifier;ILjava/lang/Object;)Lorg/partiql/ast/GroupBy; + public static final fun groupByKey (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/GroupBy$Key; public static final fun groupByKey (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/GroupBy$Key; public static synthetic fun groupByKey$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;ILjava/lang/Object;)Lorg/partiql/ast/GroupBy$Key; public static final fun identifier (Ljava/lang/String;Z)Lorg/partiql/ast/Identifier; + public static final fun identifierChain (Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/IdentifierChain; public static final fun identifierChain (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/IdentifierChain; public static synthetic fun identifierChain$default (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/IdentifierChain;ILjava/lang/Object;)Lorg/partiql/ast/IdentifierChain; + public static final fun insert (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;)Lorg/partiql/ast/dml/Insert; public static final fun insert (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;Lorg/partiql/ast/dml/OnConflict;)Lorg/partiql/ast/dml/Insert; + public static final fun insert (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/dml/InsertSource;)Lorg/partiql/ast/dml/Insert; public static synthetic fun insert$default (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;Lorg/partiql/ast/dml/OnConflict;ILjava/lang/Object;)Lorg/partiql/ast/dml/Insert; public static final fun insertSourceDefault ()Lorg/partiql/ast/dml/InsertSource$FromDefault; public static final fun insertSourceExpr (Ljava/util/List;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/InsertSource$FromExpr; + public static final fun insertSourceExpr (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/InsertSource$FromExpr; public static synthetic fun insertSourceExpr$default (Ljava/util/List;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/dml/InsertSource$FromExpr; public static final fun keyValue (Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/ast/ddl/KeyValue; public static final fun let (Ljava/util/List;)Lorg/partiql/ast/Let; public static final fun letBinding (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/Let$Binding; + public static final fun onConflict (Lorg/partiql/ast/dml/ConflictAction;)Lorg/partiql/ast/dml/OnConflict; public static final fun onConflict (Lorg/partiql/ast/dml/ConflictAction;Lorg/partiql/ast/dml/ConflictTarget;)Lorg/partiql/ast/dml/OnConflict; public static synthetic fun onConflict$default (Lorg/partiql/ast/dml/ConflictAction;Lorg/partiql/ast/dml/ConflictTarget;ILjava/lang/Object;)Lorg/partiql/ast/dml/OnConflict; public static final fun orderBy (Ljava/util/List;)Lorg/partiql/ast/OrderBy; public static final fun partitionBy (Ljava/util/List;)Lorg/partiql/ast/ddl/PartitionBy; public static final fun query (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/Query; public static final fun queryBodySFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/QueryBody$SFW; + public static final fun queryBodySFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/From;)Lorg/partiql/ast/QueryBody$SFW; + public static final fun queryBodySFW (Lorg/partiql/ast/Select;Lorg/partiql/ast/From;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/QueryBody$SFW; public static synthetic fun queryBodySFW$default (Lorg/partiql/ast/Select;Lorg/partiql/ast/Exclude;Lorg/partiql/ast/From;Lorg/partiql/ast/Let;Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/GroupBy;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/QueryBody$SFW; public static final fun queryBodySetOp (Lorg/partiql/ast/SetOp;ZLorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/QueryBody$SetOp; public static final fun replace (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;)Lorg/partiql/ast/dml/Replace; + public static final fun replace (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/dml/InsertSource;)Lorg/partiql/ast/dml/Replace; public static synthetic fun replace$default (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;ILjava/lang/Object;)Lorg/partiql/ast/dml/Replace; + public static final fun selectItemExpr (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SelectItem$Expr; public static final fun selectItemExpr (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/SelectItem$Expr; public static synthetic fun selectItemExpr$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Identifier;ILjava/lang/Object;)Lorg/partiql/ast/SelectItem$Expr; public static final fun selectItemStar (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SelectItem$Star; + public static final fun selectList (Ljava/util/List;)Lorg/partiql/ast/SelectList; public static final fun selectList (Ljava/util/List;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/SelectList; public static synthetic fun selectList$default (Ljava/util/List;Lorg/partiql/ast/SetQuantifier;ILjava/lang/Object;)Lorg/partiql/ast/SelectList; public static final fun selectPivot (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SelectPivot; + public static final fun selectStar ()Lorg/partiql/ast/SelectStar; public static final fun selectStar (Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/SelectStar; public static synthetic fun selectStar$default (Lorg/partiql/ast/SetQuantifier;ILjava/lang/Object;)Lorg/partiql/ast/SelectStar; + public static final fun selectValue (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SelectValue; public static final fun selectValue (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/SelectValue; public static synthetic fun selectValue$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/SetQuantifier;ILjava/lang/Object;)Lorg/partiql/ast/SelectValue; public static final fun setClause (Lorg/partiql/ast/dml/UpdateTarget;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/SetClause; + public static final fun setOp (Lorg/partiql/ast/SetOpType;)Lorg/partiql/ast/SetOp; public static final fun setOp (Lorg/partiql/ast/SetOpType;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/SetOp; public static synthetic fun setOp$default (Lorg/partiql/ast/SetOpType;Lorg/partiql/ast/SetQuantifier;ILjava/lang/Object;)Lorg/partiql/ast/SetOp; + public static final fun sort (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/Sort; + public static final fun sort (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Order;)Lorg/partiql/ast/Sort; public static final fun sort (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Order;Lorg/partiql/ast/Nulls;)Lorg/partiql/ast/Sort; public static synthetic fun sort$default (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Order;Lorg/partiql/ast/Nulls;ILjava/lang/Object;)Lorg/partiql/ast/Sort; + public static final fun tableConstraintUnique (Ljava/util/List;Z)Lorg/partiql/ast/ddl/TableConstraint$Unique; public static final fun tableConstraintUnique (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Z)Lorg/partiql/ast/ddl/TableConstraint$Unique; public static synthetic fun tableConstraintUnique$default (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;ZILjava/lang/Object;)Lorg/partiql/ast/ddl/TableConstraint$Unique; + public static final fun update (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;)Lorg/partiql/ast/dml/Update; public static final fun update (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/dml/Update; public static synthetic fun update$default (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Lorg/partiql/ast/expr/Expr;ILjava/lang/Object;)Lorg/partiql/ast/dml/Update; public static final fun updateTarget (Lorg/partiql/ast/Identifier;Ljava/util/List;)Lorg/partiql/ast/dml/UpdateTarget; @@ -159,6 +220,7 @@ public final class org/partiql/ast/Ast { public static final fun updateTargetStepElement (Ljava/lang/String;)Lorg/partiql/ast/dml/UpdateTargetStep$Element; public static final fun updateTargetStepField (Lorg/partiql/ast/Identifier;)Lorg/partiql/ast/dml/UpdateTargetStep$Field; public static final fun upsert (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;)Lorg/partiql/ast/dml/Upsert; + public static final fun upsert (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/dml/InsertSource;)Lorg/partiql/ast/dml/Upsert; public static synthetic fun upsert$default (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/dml/InsertSource;ILjava/lang/Object;)Lorg/partiql/ast/dml/Upsert; } diff --git a/partiql-ast/src/main/java/org/partiql/ast/expr/ExprWindow.java b/partiql-ast/src/main/java/org/partiql/ast/expr/ExprWindow.java index 6f40f77fb..9a0bdfb31 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/expr/ExprWindow.java +++ b/partiql-ast/src/main/java/org/partiql/ast/expr/ExprWindow.java @@ -67,13 +67,13 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { @lombok.Builder(builderClassName = "Builder") @EqualsAndHashCode(callSuper = false) public static class Over extends AstNode { - @Nullable + @NotNull public final List partitions; - @Nullable + @NotNull public final List sorts; - public Over(@Nullable List partitions, @Nullable List sorts) { + public Over(@NotNull List partitions, @NotNull List sorts) { this.partitions = partitions; this.sorts = sorts; } @@ -82,12 +82,8 @@ public Over(@Nullable List partitions, @Nullable List sorts) { @NotNull public Collection children() { List kids = new ArrayList<>(); - if (partitions != null) { - kids.addAll(partitions); - } - if (sorts != null) { - kids.addAll(sorts); - } + kids.addAll(partitions); + kids.addAll(sorts); return kids; } diff --git a/partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt b/partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt index a9d66f2b5..1ca4241f1 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt @@ -94,11 +94,13 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprCall(function: IdentifierChain, args: List, setq: SetQuantifier? = null): ExprCall { return ExprCall(function, args, setq) } @JvmStatic + @JvmOverloads public fun exprCase(expr: Expr? = null, branches: List, defaultExpr: Expr? = null): ExprCase { return ExprCase(expr, branches, defaultExpr) } @@ -134,6 +136,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprLike(value: Expr, pattern: Expr, escape: Expr? = null, not: Boolean): ExprLike { return ExprLike(value, pattern, escape, not) } @@ -159,6 +162,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprOperator(symbol: String, lhs: Expr? = null, rhs: Expr): ExprOperator { return ExprOperator(symbol, lhs, rhs) } @@ -169,6 +173,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprOverlay(value: Expr, placing: Expr, from: Expr, forLength: Expr? = null): ExprOverlay { return ExprOverlay(value, placing, from, forLength) } @@ -179,6 +184,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprPath(root: Expr, next: PathStep? = null): ExprPath { return ExprPath(root, next) } @@ -188,6 +194,13 @@ public object Ast { return ExprPosition(lhs, rhs) } + // query set variant with only required field; optional fields set to null + @JvmStatic + public fun exprQuerySet(body: QueryBody): ExprQuerySet { + return ExprQuerySet(body, null, null, null) + } + + // query set variant with all fields and nullable defaults set to null @JvmStatic public fun exprQuerySet(body: QueryBody, orderBy: OrderBy? = null, limit: Expr? = null, offset: Expr? = null): ExprQuerySet { return ExprQuerySet(body, orderBy, limit, offset) @@ -209,11 +222,13 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprSubstring(value: Expr, start: Expr? = null, length: Expr? = null): ExprSubstring { return ExprSubstring(value, start, length) } @JvmStatic + @JvmOverloads public fun exprTrim(value: Expr, chars: Expr? = null, trimSpec: TrimSpec? = null): ExprTrim { return ExprTrim(value, chars, trimSpec) } @@ -245,37 +260,42 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprWindow( windowFunction: WindowFunction, - exression: Expr, + expression: Expr, offset: Expr? = null, defaultValue: Expr? = null, over: ExprWindow.Over ): ExprWindow { - return ExprWindow(windowFunction, exression, offset, defaultValue, over) + return ExprWindow(windowFunction, expression, offset, defaultValue, over) } @JvmStatic - public fun exprWindowOver(partitions: List? = null, sorts: List? = null): ExprWindow.Over { + public fun exprWindowOver(partitions: List, sorts: List): ExprWindow.Over { return ExprWindow.Over(partitions, sorts) } @JvmStatic + @JvmOverloads public fun exprPathStepField(value: Identifier, next: PathStep? = null): PathStep.Field { return PathStep.Field(value, next) } @JvmStatic + @JvmOverloads public fun exprPathStepElement(element: Expr, next: PathStep? = null): PathStep.Element { return PathStep.Element(element, next) } @JvmStatic + @JvmOverloads public fun exprPathStepAllElements(next: PathStep? = null): PathStep.AllElements { return PathStep.AllElements(next) } @JvmStatic + @JvmOverloads public fun exprPathStepAllFields(next: PathStep? = null): AllFields { return AllFields(next) } @@ -307,16 +327,19 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun graphMatch(patterns: List, selector: GraphSelector? = null): GraphMatch { return GraphMatch(patterns, selector) } @JvmStatic + @JvmOverloads public fun graphMatchNode(prefilter: Expr? = null, variable: String? = null, label: GraphLabel? = null): GraphPart.Node { return GraphPart.Node(prefilter, variable, label) } @JvmStatic + @JvmOverloads public fun graphMatchEdge( direction: GraphDirection, quantifier: GraphQuantifier? = null, @@ -333,6 +356,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun graphPattern( restrictor: GraphRestrictor? = null, prefilter: Expr? = null, @@ -344,6 +368,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun graphQuantifier(lower: Long, upper: Long? = null): GraphQuantifier { return GraphQuantifier(lower, upper) } @@ -420,21 +445,25 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun fromExpr(expr: Expr, fromType: FromType, asAlias: Identifier? = null, atAlias: Identifier? = null): FromExpr { return FromExpr(expr, fromType, asAlias, atAlias) } @JvmStatic + @JvmOverloads public fun fromJoin(lhs: FromTableRef, rhs: FromTableRef, joinType: JoinType? = null, condition: Expr? = null): FromJoin { return FromJoin(lhs, rhs, joinType, condition) } @JvmStatic + @JvmOverloads public fun groupBy(strategy: GroupByStrategy, keys: List, asAlias: Identifier? = null): GroupBy { return GroupBy(strategy, keys, asAlias) } @JvmStatic + @JvmOverloads public fun groupByKey(expr: Expr, asAlias: Identifier? = null): GroupBy.Key { return GroupBy.Key(expr, asAlias) } @@ -445,6 +474,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun identifierChain(root: Identifier, next: IdentifierChain? = null): IdentifierChain { return IdentifierChain(root, next) } @@ -470,26 +500,31 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun insert(tableName: IdentifierChain, asAlias: Identifier? = null, source: InsertSource, onConflict: OnConflict? = null): Insert { return Insert(tableName, asAlias, source, onConflict) } @JvmStatic + @JvmOverloads public fun upsert(tableName: IdentifierChain, asAlias: Identifier? = null, source: InsertSource): Upsert { return Upsert(tableName, asAlias, source) } @JvmStatic + @JvmOverloads public fun replace(tableName: IdentifierChain, asAlias: Identifier? = null, source: InsertSource): Replace { return Replace(tableName, asAlias, source) } @JvmStatic + @JvmOverloads public fun update(tableName: IdentifierChain, setClauses: List, condition: Expr? = null): Update { return Update(tableName, setClauses, condition) } @JvmStatic + @JvmOverloads public fun delete(tableName: IdentifierChain, condition: Expr? = null): Delete { return Delete(tableName, condition) } @@ -500,6 +535,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun insertSourceExpr(columns: List? = null, expr: Expr): InsertSource.FromExpr { return InsertSource.FromExpr(columns, expr) } @@ -510,6 +546,7 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun onConflict(action: ConflictAction, target: ConflictTarget? = null): OnConflict { return OnConflict(action, target) } @@ -530,11 +567,13 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun doReplace(action: DoReplaceAction, condition: Expr? = null): ConflictAction.DoReplace { return ConflictAction.DoReplace(action, condition) } @JvmStatic + @JvmOverloads public fun doUpdate(action: DoUpdateAction, condition: Expr? = null): ConflictAction.DoUpdate { return ConflictAction.DoUpdate(action, condition) } @@ -569,6 +608,19 @@ public object Ast { return UpdateTargetStep.Field(key) } + // SFW variant with only required fields; optional fields are set to null + @JvmStatic + public fun queryBodySFW(select: Select, from: From): QueryBody.SFW { + return QueryBody.SFW(select, null, from, null, null, null, null) + } + + // SFW variant with `WHERE`; optional fields are set to null + @JvmStatic + public fun queryBodySFW(select: Select, from: From, where: Expr): QueryBody.SFW { + return QueryBody.SFW(select, null, from, null, where, null, null) + } + + // SFW variant with all fields and nullable defaults set to null @JvmStatic public fun queryBodySFW( select: Select, @@ -593,11 +645,13 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun selectItemExpr(expr: Expr, asAlias: Identifier? = null): SelectItem.Expr { return SelectItem.Expr(expr, asAlias) } @JvmStatic + @JvmOverloads public fun selectList(items: List, setq: SetQuantifier? = null): SelectList { return SelectList(items, setq) } @@ -608,21 +662,25 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun selectStar(setq: SetQuantifier? = null): SelectStar { return SelectStar(setq) } @JvmStatic + @JvmOverloads public fun selectValue(constructor: Expr, setq: SetQuantifier? = null): SelectValue { return SelectValue(constructor, setq) } @JvmStatic + @JvmOverloads public fun setOp(setOpType: SetOpType, setq: SetQuantifier? = null): SetOp { return SetOp(setOpType, setq) } @JvmStatic + @JvmOverloads public fun sort(expr: Expr, order: Order? = null, nulls: Nulls? = null): Sort { return Sort(expr, order, nulls) } @@ -631,6 +689,7 @@ public object Ast { // DDL // @JvmStatic + @JvmOverloads public fun createTable(name: IdentifierChain, columns: List, constraints: List, partitionBy: PartitionBy? = null, tableProperties: List): CreateTable { return CreateTable( name, @@ -642,26 +701,31 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun columnDefinition(name: Identifier, type: DataType, isOptional: Boolean, constraints: List, comment: String? = null): ColumnDefinition { return ColumnDefinition(name, type, isOptional, constraints, comment) } @JvmStatic + @JvmOverloads public fun tableConstraintUnique(name: IdentifierChain? = null, columns: List, isPrimaryKey: Boolean): TableConstraint.Unique { return TableConstraint.Unique(name, columns, isPrimaryKey) } @JvmStatic + @JvmOverloads public fun columnConstraintNullable(name: IdentifierChain? = null, isNullable: Boolean): AttributeConstraint.Null { return AttributeConstraint.Null(name, isNullable) } @JvmStatic + @JvmOverloads public fun columnConstraintUnique(name: IdentifierChain? = null, isPrimaryKey: Boolean): AttributeConstraint.Unique { return AttributeConstraint.Unique(name, isPrimaryKey) } @JvmStatic + @JvmOverloads public fun columnConstraintCheck(name: IdentifierChain? = null, searchCondition: Expr): AttributeConstraint.Check { return AttributeConstraint.Check(name, searchCondition) } diff --git a/partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt b/partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt index b54415dfd..06e594297 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt @@ -415,8 +415,8 @@ public abstract class AstRewriter : AstVisitor() { } override fun visitExprWindowOver(node: ExprWindow.Over, ctx: C): AstNode { - val partitions = node.partitions?.let { _visitList(it, ctx, ::visitExpr) } - val sorts = node.sorts?.let { _visitList(it, ctx, ::visitSort) } + val partitions = _visitList(node.partitions, ctx, ::visitExpr) + val sorts = node.sorts.let { _visitList(it, ctx, ::visitSort) } return if (partitions !== node.partitions || sorts !== node.sorts) { ExprWindow.Over(partitions, sorts) } else { 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 6897b858a..a049bec4e 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 @@ -1833,15 +1833,12 @@ internal class PartiQLParserDefault : PartiQLParser { val offset = visitOrNull(ctx.expr(1)) val default = visitOrNull(ctx.expr(2)) val over = visitOver(ctx.over()) - if (over.sorts == null) { - throw error(ctx.over(), "$function requires Window ORDER BY") - } exprWindow(function, expression, offset, default, over) } override fun visitOver(ctx: GeneratedParser.OverContext) = translate(ctx) { - val partitions = ctx.windowPartitionList()?.let { visitOrEmpty(it.expr()) } - val sorts = ctx.windowSortSpecList()?.let { visitOrEmpty(it.orderSortSpec()) } + val partitions = visitOrEmpty(ctx.windowPartitionList().expr()) + val sorts = visitOrEmpty(ctx.windowSortSpecList().orderSortSpec()) exprWindowOver(partitions, sorts) }