From 158b814bf81abf6b4e686c53d2ccf88e30ea6770 Mon Sep 17 00:00:00 2001 From: Alan Cai <caialan@amazon.com> Date: Fri, 13 Dec 2024 15:17:03 -0800 Subject: [PATCH] [v1] Add null defaults to AST factory methods (#1675) --- partiql-ast/api/partiql-ast.api | 109 +++++++++++ .../java/org/partiql/ast/expr/ExprWindow.java | 16 +- .../src/main/kotlin/org/partiql/ast/Ast.kt | 184 ++++++++++++------ .../kotlin/org/partiql/ast/AstRewriter.kt | 4 +- .../parser/internal/PartiQLParserDefault.kt | 7 +- 5 files changed, 244 insertions(+), 76 deletions(-) diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index b6c444f298..06f809ca2a 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -1,17 +1,33 @@ 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; public static final fun exclude (Ljava/util/List;)Lorg/partiql/ast/Exclude; public static final fun excludePath (Lorg/partiql/ast/expr/ExprVarRef;Ljava/util/List;)Lorg/partiql/ast/ExcludePath; @@ -24,8 +40,13 @@ 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; public static final fun exprCast (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/DataType;)Lorg/partiql/ast/expr/ExprCast; public static final fun exprCoalesce (Ljava/util/List;)Lorg/partiql/ast/expr/ExprCoalesce; @@ -33,86 +54,174 @@ 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; public static final fun exprRowValue (Ljava/util/List;Z)Lorg/partiql/ast/expr/ExprRowValue; 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 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; public static final fun graphLabelDisj (Lorg/partiql/ast/graph/GraphLabel;Lorg/partiql/ast/graph/GraphLabel;)Lorg/partiql/ast/graph/GraphLabel$Disj; 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; public static final fun graphSelectorAny ()Lorg/partiql/ast/graph/GraphSelector$Any; public static final fun graphSelectorAnyK (J)Lorg/partiql/ast/graph/GraphSelector$AnyK; 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; public static final fun updateTargetStepElement (I)Lorg/partiql/ast/dml/UpdateTargetStep$Element; 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; } public abstract class org/partiql/ast/AstEnum : org/partiql/ast/AstNode { 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 68055c0ccd..f84067077f 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 @@ -66,13 +66,15 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { @lombok.Builder(builderClassName = "Builder") @EqualsAndHashCode(callSuper = false) public static class Over extends AstNode { - @Nullable + // Empty list represents no `PARTITION BY` specifications + @NotNull public final List<Expr> partitions; - @Nullable + // Empty list represents no `ORDER BY` specifications + @NotNull public final List<Sort> sorts; - public Over(@Nullable List<Expr> partitions, @Nullable List<Sort> sorts) { + public Over(@NotNull List<Expr> partitions, @NotNull List<Sort> sorts) { this.partitions = partitions; this.sorts = sorts; } @@ -81,12 +83,8 @@ public Over(@Nullable List<Expr> partitions, @Nullable List<Sort> sorts) { @NotNull public List<AstNode> getChildren() { List<AstNode> 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 b11360b423..1ca4241f1f 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/Ast.kt @@ -94,12 +94,14 @@ public object Ast { } @JvmStatic - public fun exprCall(function: IdentifierChain, args: List<Expr>, setq: SetQuantifier?): ExprCall { + @JvmOverloads + public fun exprCall(function: IdentifierChain, args: List<Expr>, setq: SetQuantifier? = null): ExprCall { return ExprCall(function, args, setq) } @JvmStatic - public fun exprCase(expr: Expr?, branches: List<ExprCase.Branch>, defaultExpr: Expr?): ExprCase { + @JvmOverloads + public fun exprCase(expr: Expr? = null, branches: List<ExprCase.Branch>, defaultExpr: Expr? = null): ExprCase { return ExprCase(expr, branches, defaultExpr) } @@ -134,7 +136,8 @@ public object Ast { } @JvmStatic - public fun exprLike(value: Expr, pattern: Expr, escape: Expr?, not: Boolean): ExprLike { + @JvmOverloads + public fun exprLike(value: Expr, pattern: Expr, escape: Expr? = null, not: Boolean): ExprLike { return ExprLike(value, pattern, escape, not) } @@ -159,7 +162,8 @@ public object Ast { } @JvmStatic - public fun exprOperator(symbol: String, lhs: Expr?, rhs: Expr): ExprOperator { + @JvmOverloads + public fun exprOperator(symbol: String, lhs: Expr? = null, rhs: Expr): ExprOperator { return ExprOperator(symbol, lhs, rhs) } @@ -169,7 +173,8 @@ public object Ast { } @JvmStatic - public fun exprOverlay(value: Expr, placing: Expr, from: Expr, forLength: Expr?): ExprOverlay { + @JvmOverloads + public fun exprOverlay(value: Expr, placing: Expr, from: Expr, forLength: Expr? = null): ExprOverlay { return ExprOverlay(value, placing, from, forLength) } @@ -179,7 +184,8 @@ public object Ast { } @JvmStatic - public fun exprPath(root: Expr, next: PathStep?): ExprPath { + @JvmOverloads + public fun exprPath(root: Expr, next: PathStep? = null): ExprPath { return ExprPath(root, next) } @@ -188,8 +194,15 @@ 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, orderBy: OrderBy?, limit: Expr?, offset: Expr?): ExprQuerySet { + 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,12 +222,14 @@ public object Ast { } @JvmStatic - public fun exprSubstring(value: Expr, start: Expr?, length: Expr?): ExprSubstring { + @JvmOverloads + public fun exprSubstring(value: Expr, start: Expr? = null, length: Expr? = null): ExprSubstring { return ExprSubstring(value, start, length) } @JvmStatic - public fun exprTrim(value: Expr, chars: Expr?, trimSpec: TrimSpec?): ExprTrim { + @JvmOverloads + public fun exprTrim(value: Expr, chars: Expr? = null, trimSpec: TrimSpec? = null): ExprTrim { return ExprTrim(value, chars, trimSpec) } @@ -245,38 +260,43 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun exprWindow( windowFunction: WindowFunction, - exression: Expr, - offset: Expr?, - defaultValue: 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<Expr>?, sorts: List<Sort>?): ExprWindow.Over { + public fun exprWindowOver(partitions: List<Expr>, sorts: List<Sort>): ExprWindow.Over { return ExprWindow.Over(partitions, sorts) } @JvmStatic - public fun exprPathStepField(value: Identifier, next: PathStep?): PathStep.Field { + @JvmOverloads + public fun exprPathStepField(value: Identifier, next: PathStep? = null): PathStep.Field { return PathStep.Field(value, next) } @JvmStatic - public fun exprPathStepElement(element: Expr, next: PathStep?): PathStep.Element { + @JvmOverloads + public fun exprPathStepElement(element: Expr, next: PathStep? = null): PathStep.Element { return PathStep.Element(element, next) } @JvmStatic - public fun exprPathStepAllElements(next: PathStep?): PathStep.AllElements { + @JvmOverloads + public fun exprPathStepAllElements(next: PathStep? = null): PathStep.AllElements { return PathStep.AllElements(next) } @JvmStatic - public fun exprPathStepAllFields(next: PathStep?): AllFields { + @JvmOverloads + public fun exprPathStepAllFields(next: PathStep? = null): AllFields { return AllFields(next) } @@ -307,22 +327,25 @@ public object Ast { } @JvmStatic - public fun graphMatch(patterns: List<GraphPattern>, selector: GraphSelector?): GraphMatch { + @JvmOverloads + public fun graphMatch(patterns: List<GraphPattern>, selector: GraphSelector? = null): GraphMatch { return GraphMatch(patterns, selector) } @JvmStatic - public fun graphMatchNode(prefilter: Expr?, variable: String?, label: GraphLabel?): GraphPart.Node { + @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?, - prefilter: Expr?, - variable: String?, - label: GraphLabel? + quantifier: GraphQuantifier? = null, + prefilter: Expr? = null, + variable: String? = null, + label: GraphLabel? = null ): GraphPart.Edge { return GraphPart.Edge(direction, quantifier, prefilter, variable, label) } @@ -333,18 +356,20 @@ public object Ast { } @JvmStatic + @JvmOverloads public fun graphPattern( - restrictor: GraphRestrictor?, - prefilter: Expr?, - variable: String?, - quantifier: GraphQuantifier?, + restrictor: GraphRestrictor? = null, + prefilter: Expr? = null, + variable: String? = null, + quantifier: GraphQuantifier? = null, parts: List<GraphPart> ): GraphPattern { return GraphPattern(restrictor, prefilter, variable, quantifier, parts) } @JvmStatic - public fun graphQuantifier(lower: Long, upper: Long?): GraphQuantifier { + @JvmOverloads + public fun graphQuantifier(lower: Long, upper: Long? = null): GraphQuantifier { return GraphQuantifier(lower, upper) } @@ -420,22 +445,26 @@ public object Ast { } @JvmStatic - public fun fromExpr(expr: Expr, fromType: FromType, asAlias: Identifier?, atAlias: Identifier?): FromExpr { + @JvmOverloads + public fun fromExpr(expr: Expr, fromType: FromType, asAlias: Identifier? = null, atAlias: Identifier? = null): FromExpr { return FromExpr(expr, fromType, asAlias, atAlias) } @JvmStatic - public fun fromJoin(lhs: FromTableRef, rhs: FromTableRef, joinType: JoinType?, condition: Expr?): FromJoin { + @JvmOverloads + public fun fromJoin(lhs: FromTableRef, rhs: FromTableRef, joinType: JoinType? = null, condition: Expr? = null): FromJoin { return FromJoin(lhs, rhs, joinType, condition) } @JvmStatic - public fun groupBy(strategy: GroupByStrategy, keys: List<GroupBy.Key>, asAlias: Identifier?): GroupBy { + @JvmOverloads + public fun groupBy(strategy: GroupByStrategy, keys: List<GroupBy.Key>, asAlias: Identifier? = null): GroupBy { return GroupBy(strategy, keys, asAlias) } @JvmStatic - public fun groupByKey(expr: Expr, asAlias: Identifier?): GroupBy.Key { + @JvmOverloads + public fun groupByKey(expr: Expr, asAlias: Identifier? = null): GroupBy.Key { return GroupBy.Key(expr, asAlias) } @@ -445,7 +474,8 @@ public object Ast { } @JvmStatic - public fun identifierChain(root: Identifier, next: IdentifierChain?): IdentifierChain { + @JvmOverloads + public fun identifierChain(root: Identifier, next: IdentifierChain? = null): IdentifierChain { return IdentifierChain(root, next) } @@ -470,27 +500,32 @@ public object Ast { } @JvmStatic - public fun insert(tableName: IdentifierChain, asAlias: Identifier?, source: InsertSource, onConflict: OnConflict?): Insert { + @JvmOverloads + public fun insert(tableName: IdentifierChain, asAlias: Identifier? = null, source: InsertSource, onConflict: OnConflict? = null): Insert { return Insert(tableName, asAlias, source, onConflict) } @JvmStatic - public fun upsert(tableName: IdentifierChain, asAlias: Identifier?, source: InsertSource): Upsert { + @JvmOverloads + public fun upsert(tableName: IdentifierChain, asAlias: Identifier? = null, source: InsertSource): Upsert { return Upsert(tableName, asAlias, source) } @JvmStatic - public fun replace(tableName: IdentifierChain, asAlias: Identifier?, source: InsertSource): Replace { + @JvmOverloads + public fun replace(tableName: IdentifierChain, asAlias: Identifier? = null, source: InsertSource): Replace { return Replace(tableName, asAlias, source) } @JvmStatic - public fun update(tableName: IdentifierChain, setClauses: List<SetClause>, condition: Expr?): Update { + @JvmOverloads + public fun update(tableName: IdentifierChain, setClauses: List<SetClause>, condition: Expr? = null): Update { return Update(tableName, setClauses, condition) } @JvmStatic - public fun delete(tableName: IdentifierChain, condition: Expr?): Delete { + @JvmOverloads + public fun delete(tableName: IdentifierChain, condition: Expr? = null): Delete { return Delete(tableName, condition) } @@ -500,7 +535,8 @@ public object Ast { } @JvmStatic - public fun insertSourceExpr(columns: List<Identifier>?, expr: Expr): InsertSource.FromExpr { + @JvmOverloads + public fun insertSourceExpr(columns: List<Identifier>? = null, expr: Expr): InsertSource.FromExpr { return InsertSource.FromExpr(columns, expr) } @@ -510,7 +546,8 @@ public object Ast { } @JvmStatic - public fun onConflict(action: ConflictAction, target: ConflictTarget?): OnConflict { + @JvmOverloads + public fun onConflict(action: ConflictAction, target: ConflictTarget? = null): OnConflict { return OnConflict(action, target) } @@ -530,12 +567,14 @@ public object Ast { } @JvmStatic - public fun doReplace(action: DoReplaceAction, condition: Expr?): ConflictAction.DoReplace { + @JvmOverloads + public fun doReplace(action: DoReplaceAction, condition: Expr? = null): ConflictAction.DoReplace { return ConflictAction.DoReplace(action, condition) } @JvmStatic - public fun doUpdate(action: DoUpdateAction, condition: Expr?): ConflictAction.DoUpdate { + @JvmOverloads + public fun doUpdate(action: DoUpdateAction, condition: Expr? = null): ConflictAction.DoUpdate { return ConflictAction.DoUpdate(action, condition) } @@ -569,15 +608,28 @@ 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, - exclude: Exclude?, + exclude: Exclude? = null, from: From, - let: Let?, - where: Expr?, - groupBy: GroupBy?, - having: Expr? + let: Let? = null, + where: Expr? = null, + groupBy: GroupBy? = null, + having: Expr? = null ): QueryBody.SFW { return QueryBody.SFW(select, exclude, from, let, where, groupBy, having) } @@ -593,12 +645,14 @@ public object Ast { } @JvmStatic - public fun selectItemExpr(expr: Expr, asAlias: Identifier?): SelectItem.Expr { + @JvmOverloads + public fun selectItemExpr(expr: Expr, asAlias: Identifier? = null): SelectItem.Expr { return SelectItem.Expr(expr, asAlias) } @JvmStatic - public fun selectList(items: List<SelectItem>, setq: SetQuantifier?): SelectList { + @JvmOverloads + public fun selectList(items: List<SelectItem>, setq: SetQuantifier? = null): SelectList { return SelectList(items, setq) } @@ -608,22 +662,26 @@ public object Ast { } @JvmStatic - public fun selectStar(setq: SetQuantifier?): SelectStar { + @JvmOverloads + public fun selectStar(setq: SetQuantifier? = null): SelectStar { return SelectStar(setq) } @JvmStatic - public fun selectValue(constructor: Expr, setq: SetQuantifier?): SelectValue { + @JvmOverloads + public fun selectValue(constructor: Expr, setq: SetQuantifier? = null): SelectValue { return SelectValue(constructor, setq) } @JvmStatic - public fun setOp(setOpType: SetOpType, setq: SetQuantifier?): SetOp { + @JvmOverloads + public fun setOp(setOpType: SetOpType, setq: SetQuantifier? = null): SetOp { return SetOp(setOpType, setq) } @JvmStatic - public fun sort(expr: Expr, order: Order?, nulls: Nulls?): Sort { + @JvmOverloads + public fun sort(expr: Expr, order: Order? = null, nulls: Nulls? = null): Sort { return Sort(expr, order, nulls) } @@ -631,7 +689,8 @@ public object Ast { // DDL // @JvmStatic - public fun createTable(name: IdentifierChain, columns: List<ColumnDefinition>, constraints: List<TableConstraint>, partitionBy: PartitionBy?, tableProperties: List<KeyValue>): CreateTable { + @JvmOverloads + public fun createTable(name: IdentifierChain, columns: List<ColumnDefinition>, constraints: List<TableConstraint>, partitionBy: PartitionBy? = null, tableProperties: List<KeyValue>): CreateTable { return CreateTable( name, columns, @@ -642,27 +701,32 @@ public object Ast { } @JvmStatic - public fun columnDefinition(name: Identifier, type: DataType, isOptional: Boolean, constraints: List<AttributeConstraint>, comment: String?): ColumnDefinition { + @JvmOverloads + public fun columnDefinition(name: Identifier, type: DataType, isOptional: Boolean, constraints: List<AttributeConstraint>, comment: String? = null): ColumnDefinition { return ColumnDefinition(name, type, isOptional, constraints, comment) } @JvmStatic - public fun tableConstraintUnique(name: IdentifierChain?, columns: List<Identifier>, isPrimaryKey: Boolean): TableConstraint.Unique { + @JvmOverloads + public fun tableConstraintUnique(name: IdentifierChain? = null, columns: List<Identifier>, isPrimaryKey: Boolean): TableConstraint.Unique { return TableConstraint.Unique(name, columns, isPrimaryKey) } @JvmStatic - public fun columnConstraintNullable(name: IdentifierChain?, isNullable: Boolean): AttributeConstraint.Null { + @JvmOverloads + public fun columnConstraintNullable(name: IdentifierChain? = null, isNullable: Boolean): AttributeConstraint.Null { return AttributeConstraint.Null(name, isNullable) } @JvmStatic - public fun columnConstraintUnique(name: IdentifierChain?, isPrimaryKey: Boolean): AttributeConstraint.Unique { + @JvmOverloads + public fun columnConstraintUnique(name: IdentifierChain? = null, isPrimaryKey: Boolean): AttributeConstraint.Unique { return AttributeConstraint.Unique(name, isPrimaryKey) } @JvmStatic - public fun columnConstraintCheck(name: IdentifierChain?, searchCondition: Expr): AttributeConstraint.Check { + @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 b54415dfd7..06e5942972 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<C> : AstVisitor<AstNode, C>() { } 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 d6cfdfa3f3..77142e8a4a 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 @@ -1836,15 +1836,12 @@ internal class PartiQLParserDefault : PartiQLParser { val offset = visitOrNull<Expr>(ctx.expr(1)) val default = visitOrNull<Expr>(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<Expr>(it.expr()) } - val sorts = ctx.windowSortSpecList()?.let { visitOrEmpty<Sort>(it.orderSortSpec()) } + val partitions = visitOrEmpty<Expr>(ctx.windowPartitionList().expr()) + val sorts = visitOrEmpty<Sort>(ctx.windowSortSpecList().orderSortSpec()) exprWindowOver(partitions, sorts) }