Skip to content

Commit

Permalink
Renames AST FromSubquery to FromExpr
Browse files Browse the repository at this point in the history
Removes InsertColumnList AST node

Fixes the passing of some AST children

Updates Javadocs

Adds tests for explicit use of ROW
  • Loading branch information
johnedquinn committed Dec 6, 2024
1 parent a04b454 commit 429b5d3
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 130 deletions.
41 changes: 12 additions & 29 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public final class org/partiql/ast/Ast {
public static final fun identifierChain (Lorg/partiql/ast/Identifier;Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/IdentifierChain;
public static final fun insert (Lorg/partiql/ast/IdentifierChain;Lorg/partiql/ast/Identifier;Lorg/partiql/ast/InsertSource;Lorg/partiql/ast/OnConflict;)Lorg/partiql/ast/Insert;
public static final fun insertSourceDefault ()Lorg/partiql/ast/InsertSource$FromDefault;
public static final fun insertSourceExpr (Ljava/util/List;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/InsertSource$FromSubquery;
public static final fun insertSourceExpr (Ljava/util/List;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/InsertSource$FromExpr;
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/ConflictAction;Lorg/partiql/ast/ConflictTarget;)Lorg/partiql/ast/OnConflict;
Expand All @@ -96,7 +96,7 @@ public final class org/partiql/ast/Ast {
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/SetQuantifier;)Lorg/partiql/ast/SelectStar;
public static final fun selectValue (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/SelectValue;
public static final fun setClause (Lorg/partiql/ast/AstNode;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SetClause;
public static final fun setClause (Lorg/partiql/ast/UpdateTarget;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SetClause;
public static final fun setOp (Lorg/partiql/ast/SetOpType;Lorg/partiql/ast/SetQuantifier;)Lorg/partiql/ast/SetOp;
public static final fun sort (Lorg/partiql/ast/expr/Expr;Lorg/partiql/ast/Order;Lorg/partiql/ast/Nulls;)Lorg/partiql/ast/Sort;
public static final fun update (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/Update;
Expand Down Expand Up @@ -365,10 +365,9 @@ public abstract class org/partiql/ast/AstVisitor {
public fun visitIdentifier (Lorg/partiql/ast/Identifier;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitIdentifierChain (Lorg/partiql/ast/IdentifierChain;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitInsert (Lorg/partiql/ast/Insert;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitInsertColumnList (Lorg/partiql/ast/InsertColumnList;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitInsertSource (Lorg/partiql/ast/InsertSource;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitInsertSourceFromDefault (Lorg/partiql/ast/InsertSource$FromDefault;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitInsertSourceFromSubquery (Lorg/partiql/ast/InsertSource$FromSubquery;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitInsertSourceFromExpr (Lorg/partiql/ast/InsertSource$FromExpr;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitLet (Lorg/partiql/ast/Let;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitLetBinding (Lorg/partiql/ast/Let$Binding;Ljava/lang/Object;)Ljava/lang/Object;
public fun visitOnConflict (Lorg/partiql/ast/OnConflict;Ljava/lang/Object;)Ljava/lang/Object;
Expand Down Expand Up @@ -1032,22 +1031,6 @@ public class org/partiql/ast/Insert$Builder {
public fun toString ()Ljava/lang/String;
}

public final class org/partiql/ast/InsertColumnList : org/partiql/ast/Statement {
public final field columns Ljava/util/List;
public fun <init> (Ljava/util/List;)V
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
public static fun builder ()Lorg/partiql/ast/InsertColumnList$Builder;
public fun children ()Ljava/util/Collection;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
}

public class org/partiql/ast/InsertColumnList$Builder {
public fun build ()Lorg/partiql/ast/InsertColumnList;
public fun columns (Ljava/util/List;)Lorg/partiql/ast/InsertColumnList$Builder;
public fun toString ()Ljava/lang/String;
}

public abstract class org/partiql/ast/InsertSource : org/partiql/ast/AstNode {
public fun <init> ()V
}
Expand All @@ -1065,21 +1048,21 @@ public class org/partiql/ast/InsertSource$FromDefault$Builder {
public fun toString ()Ljava/lang/String;
}

public final class org/partiql/ast/InsertSource$FromSubquery : org/partiql/ast/InsertSource {
public final class org/partiql/ast/InsertSource$FromExpr : org/partiql/ast/InsertSource {
public final field columns Ljava/util/List;
public final field expr Lorg/partiql/ast/expr/Expr;
public fun <init> (Ljava/util/List;Lorg/partiql/ast/expr/Expr;)V
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
public static fun builder ()Lorg/partiql/ast/InsertSource$FromSubquery$Builder;
public static fun builder ()Lorg/partiql/ast/InsertSource$FromExpr$Builder;
public fun children ()Ljava/util/Collection;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
}

public class org/partiql/ast/InsertSource$FromSubquery$Builder {
public fun build ()Lorg/partiql/ast/InsertSource$FromSubquery;
public fun columns (Ljava/util/List;)Lorg/partiql/ast/InsertSource$FromSubquery$Builder;
public fun expr (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/InsertSource$FromSubquery$Builder;
public class org/partiql/ast/InsertSource$FromExpr$Builder {
public fun build ()Lorg/partiql/ast/InsertSource$FromExpr;
public fun columns (Ljava/util/List;)Lorg/partiql/ast/InsertSource$FromExpr$Builder;
public fun expr (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/InsertSource$FromExpr$Builder;
public fun toString ()Ljava/lang/String;
}

Expand Down Expand Up @@ -1432,8 +1415,8 @@ public class org/partiql/ast/SelectValue$Builder {

public final class org/partiql/ast/SetClause : org/partiql/ast/AstNode {
public final field expr Lorg/partiql/ast/expr/Expr;
public final field target Lorg/partiql/ast/AstNode;
public fun <init> (Lorg/partiql/ast/AstNode;Lorg/partiql/ast/expr/Expr;)V
public final field target Lorg/partiql/ast/UpdateTarget;
public fun <init> (Lorg/partiql/ast/UpdateTarget;Lorg/partiql/ast/expr/Expr;)V
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
public static fun builder ()Lorg/partiql/ast/SetClause$Builder;
public fun children ()Ljava/util/Collection;
Expand All @@ -1444,7 +1427,7 @@ public final class org/partiql/ast/SetClause : org/partiql/ast/AstNode {
public class org/partiql/ast/SetClause$Builder {
public fun build ()Lorg/partiql/ast/SetClause;
public fun expr (Lorg/partiql/ast/expr/Expr;)Lorg/partiql/ast/SetClause$Builder;
public fun target (Lorg/partiql/ast/AstNode;)Lorg/partiql/ast/SetClause$Builder;
public fun target (Lorg/partiql/ast/UpdateTarget;)Lorg/partiql/ast/SetClause$Builder;
public fun toString ()Ljava/lang/String;
}

Expand Down
6 changes: 1 addition & 5 deletions partiql-ast/src/main/java/org/partiql/ast/AstVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,11 @@ public R visitSetClause(SetClause node, C ctx) {
return defaultVisit(node, ctx);
}

public R visitInsertColumnList(InsertColumnList node, C ctx) {
return defaultVisit(node, ctx);
}

public R visitInsertSource(InsertSource node, C ctx) {
return node.accept(this, ctx);
}

public R visitInsertSourceFromSubquery(InsertSource.FromSubquery node, C ctx) {
public R visitInsertSourceFromExpr(InsertSource.FromExpr node, C ctx) {
return defaultVisit(node, ctx);
}

Expand Down
6 changes: 0 additions & 6 deletions partiql-ast/src/main/java/org/partiql/ast/ConflictAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public abstract class ConflictAction extends AstNode {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class DoNothing extends ConflictAction {
// TODO: Equals and hashcode

@NotNull
@Override
public Collection<AstNode> children() {
Expand All @@ -49,8 +47,6 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class DoReplace extends ConflictAction {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down Expand Up @@ -99,8 +95,6 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class DoUpdate extends ConflictAction {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down
5 changes: 0 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/ConflictTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public abstract class ConflictTarget extends AstNode {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class Index extends ConflictTarget {
// TODO: Do we like this name?
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down Expand Up @@ -61,8 +58,6 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class Constraint extends ConflictTarget {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down
9 changes: 4 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/Delete.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
import java.util.List;

/**
* This is the update searched statement.
* @see InsertColumnList
* @see InsertSource
* This is the delete searched statement.
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class Delete extends Statement {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down Expand Up @@ -47,6 +43,9 @@ public Delete(@NotNull IdentifierChain tableName, @Nullable Expr condition) {
public Collection<AstNode> children() {
List<AstNode> kids = new ArrayList<>();
kids.add(tableName);
if (condition != null) {
kids.add(condition);
}
return kids;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public abstract class DoReplaceAction extends AstNode {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class Excluded extends DoReplaceAction {
// TODO: Equals and hashcode

@NotNull
@Override
public Collection<AstNode> children() {
Expand Down
2 changes: 0 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/DoUpdateAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public abstract class DoUpdateAction extends AstNode {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class Excluded extends DoUpdateAction {
// TODO: Equals and hashcode

@NotNull
@Override
public Collection<AstNode> children() {
Expand Down
3 changes: 0 additions & 3 deletions partiql-ast/src/main/java/org/partiql/ast/Insert.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@

/**
* This is the insert statement.
* @see InsertColumnList
* @see InsertSource
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class Insert extends Statement {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down
37 changes: 0 additions & 37 deletions partiql-ast/src/main/java/org/partiql/ast/InsertColumnList.java

This file was deleted.

13 changes: 5 additions & 8 deletions partiql-ast/src/main/java/org/partiql/ast/InsertSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
public abstract class InsertSource extends AstNode {

/**
* This specifies the data to be inserted from a subquery or expression.
* This specifies the data to be inserted from a subquery or expression. This represents (and generalizes)
* SQL:1999's &lt;from subquery&gt; EBNF rule.
* @see Insert
* @see InsertSource
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class FromSubquery extends InsertSource {
// TODO: Equals and hashcode

public static final class FromExpr extends InsertSource {
/**
* TODO
*/
Expand All @@ -43,7 +42,7 @@ public static final class FromSubquery extends InsertSource {
* @param columns TODO
* @param expr TODO
*/
public FromSubquery(@Nullable List<Identifier> columns, @NotNull Expr expr) {
public FromExpr(@Nullable List<Identifier> columns, @NotNull Expr expr) {
this.columns = columns;
this.expr = expr;
}
Expand All @@ -61,7 +60,7 @@ public Collection<AstNode> children() {

@Override
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
return visitor.visitInsertSourceFromSubquery(this, ctx);
return visitor.visitInsertSourceFromExpr(this, ctx);
}
}

Expand All @@ -73,8 +72,6 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static final class FromDefault extends InsertSource {
// TODO: Equals and hashcode

@NotNull
@Override
public Collection<AstNode> children() {
Expand Down
2 changes: 0 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/OnConflict.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class OnConflict extends AstNode {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down
2 changes: 0 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/Replace.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class Replace extends Statement {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down
6 changes: 2 additions & 4 deletions partiql-ast/src/main/java/org/partiql/ast/SetClause.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class SetClause extends AstNode {
// TODO: Equals and hashcode

/**
* TODO
*/
@NotNull
public final AstNode target;
public final UpdateTarget target;

/**
* TODO
Expand All @@ -35,7 +33,7 @@ public final class SetClause extends AstNode {
* @param target TODO
* @param expr TODO
*/
public SetClause(@NotNull AstNode target, @NotNull Expr expr) {
public SetClause(@NotNull UpdateTarget target, @NotNull Expr expr) {
this.target = target;
this.expr = expr;
}
Expand Down
9 changes: 5 additions & 4 deletions partiql-ast/src/main/java/org/partiql/ast/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@

/**
* This is the update searched statement.
* @see InsertColumnList
* @see InsertSource
* @see SetClause
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class Update extends Statement {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down Expand Up @@ -55,6 +52,10 @@ public Update(@NotNull IdentifierChain tableName, @NotNull List<SetClause> setCl
public Collection<AstNode> children() {
List<AstNode> kids = new ArrayList<>();
kids.add(tableName);
kids.addAll(setClauses);
if (condition != null) {
kids.add(condition);
}
return kids;
}

Expand Down
2 changes: 0 additions & 2 deletions partiql-ast/src/main/java/org/partiql/ast/UpdateTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public final class UpdateTarget extends AstNode {
// TODO: Equals and hashcode

/**
* TODO
*/
Expand Down
Loading

0 comments on commit 429b5d3

Please sign in to comment.