From afb7808427b3e96a58f6796c492281495f9e6bdb Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Thu, 26 Dec 2024 14:58:03 -0500 Subject: [PATCH] [v1] Remove top-level DDL node --- partiql-ast/api/partiql-ast.api | 15 +++++---------- .../src/main/java/org/partiql/ast/AstVisitor.java | 5 ----- .../java/org/partiql/ast/ddl/CreateTable.java | 3 ++- .../src/main/java/org/partiql/ast/ddl/Ddl.java | 9 --------- .../main/java/org/partiql/ast/sql/SqlDialect.kt | 6 +++--- .../main/kotlin/org/partiql/ast/AstRewriter.kt | 6 +++--- 6 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 partiql-ast/src/main/java/org/partiql/ast/ddl/Ddl.java diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index 019c58084..7273dafc5 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -257,8 +257,8 @@ public abstract class org/partiql/ast/AstRewriter : org/partiql/ast/AstVisitor { public fun visitConflictTargetConstraint (Lorg/partiql/ast/dml/ConflictTarget$Constraint;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitConflictTargetIndex (Lorg/partiql/ast/dml/ConflictTarget$Index;Ljava/lang/Object;)Ljava/lang/Object; public fun visitConflictTargetIndex (Lorg/partiql/ast/dml/ConflictTarget$Index;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; - public synthetic fun visitDdl (Lorg/partiql/ast/ddl/Ddl;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitDdl (Lorg/partiql/ast/ddl/Ddl;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; + public synthetic fun visitCreateTable (Lorg/partiql/ast/ddl/CreateTable;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCreateTable (Lorg/partiql/ast/ddl/CreateTable;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitDelete (Lorg/partiql/ast/dml/Delete;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDelete (Lorg/partiql/ast/dml/Delete;Ljava/lang/Object;)Lorg/partiql/ast/AstNode; public synthetic fun visitDoReplaceActionExcluded (Lorg/partiql/ast/dml/DoReplaceAction$Excluded;Ljava/lang/Object;)Ljava/lang/Object; @@ -461,7 +461,6 @@ public abstract class org/partiql/ast/AstVisitor { public fun visitConflictTargetIndex (Lorg/partiql/ast/dml/ConflictTarget$Index;Ljava/lang/Object;)Ljava/lang/Object; public fun visitCreateTable (Lorg/partiql/ast/ddl/CreateTable;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDataType (Lorg/partiql/ast/DataType;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitDdl (Lorg/partiql/ast/ddl/Ddl;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDelete (Lorg/partiql/ast/dml/Delete;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDoReplaceAction (Lorg/partiql/ast/dml/DoReplaceAction;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDoReplaceActionExcluded (Lorg/partiql/ast/dml/DoReplaceAction$Excluded;Ljava/lang/Object;)Ljava/lang/Object; @@ -1514,7 +1513,7 @@ public class org/partiql/ast/ddl/ColumnDefinition$Builder { public fun toString ()Ljava/lang/String; } -public final class org/partiql/ast/ddl/CreateTable : org/partiql/ast/ddl/Ddl { +public final class org/partiql/ast/ddl/CreateTable : org/partiql/ast/Statement { public fun (Lorg/partiql/ast/IdentifierChain;Ljava/util/List;Ljava/util/List;Lorg/partiql/ast/ddl/PartitionBy;Ljava/util/List;)V public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public static fun builder ()Lorg/partiql/ast/ddl/CreateTable$Builder; @@ -1538,10 +1537,6 @@ public class org/partiql/ast/ddl/CreateTable$Builder { public fun toString ()Ljava/lang/String; } -public abstract class org/partiql/ast/ddl/Ddl : org/partiql/ast/Statement { - public fun ()V -} - public final class org/partiql/ast/ddl/KeyValue : org/partiql/ast/AstNode { public fun (Ljava/lang/String;Ljava/lang/String;)V public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; @@ -3176,10 +3171,10 @@ public abstract class org/partiql/ast/sql/SqlDialect : org/partiql/ast/AstVisito public fun defaultReturn (Lorg/partiql/ast/AstNode;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public static final fun getSTANDARD ()Lorg/partiql/ast/sql/SqlDialect; public final fun transform (Lorg/partiql/ast/AstNode;)Lorg/partiql/ast/sql/SqlBlock; + public synthetic fun visitCreateTable (Lorg/partiql/ast/ddl/CreateTable;Ljava/lang/Object;)Ljava/lang/Object; + public fun visitCreateTable (Lorg/partiql/ast/ddl/CreateTable;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitDataType (Lorg/partiql/ast/DataType;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDataType (Lorg/partiql/ast/DataType;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; - public synthetic fun visitDdl (Lorg/partiql/ast/ddl/Ddl;Ljava/lang/Object;)Ljava/lang/Object; - public fun visitDdl (Lorg/partiql/ast/ddl/Ddl;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitDelete (Lorg/partiql/ast/dml/Delete;Ljava/lang/Object;)Ljava/lang/Object; public fun visitDelete (Lorg/partiql/ast/dml/Delete;Lorg/partiql/ast/sql/SqlBlock;)Lorg/partiql/ast/sql/SqlBlock; public synthetic fun visitExclude (Lorg/partiql/ast/Exclude;Ljava/lang/Object;)Ljava/lang/Object; diff --git a/partiql-ast/src/main/java/org/partiql/ast/AstVisitor.java b/partiql-ast/src/main/java/org/partiql/ast/AstVisitor.java index 14d8c62a0..acb668eb0 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/AstVisitor.java +++ b/partiql-ast/src/main/java/org/partiql/ast/AstVisitor.java @@ -3,7 +3,6 @@ import org.partiql.ast.ddl.AttributeConstraint; import org.partiql.ast.ddl.ColumnDefinition; import org.partiql.ast.ddl.CreateTable; -import org.partiql.ast.ddl.Ddl; import org.partiql.ast.ddl.KeyValue; import org.partiql.ast.ddl.PartitionBy; import org.partiql.ast.ddl.TableConstraint; @@ -88,10 +87,6 @@ public R visitStatement(Statement node, C ctx) { // // DDL // - public R visitDdl(Ddl node, C ctx) { - return defaultVisit(node, ctx); - } - public R visitCreateTable(CreateTable node, C ctx) { return defaultVisit(node, ctx); } diff --git a/partiql-ast/src/main/java/org/partiql/ast/ddl/CreateTable.java b/partiql-ast/src/main/java/org/partiql/ast/ddl/CreateTable.java index 08a00253e..71f6214ea 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/ddl/CreateTable.java +++ b/partiql-ast/src/main/java/org/partiql/ast/ddl/CreateTable.java @@ -8,6 +8,7 @@ import org.partiql.ast.AstNode; import org.partiql.ast.AstVisitor; import org.partiql.ast.IdentifierChain; +import org.partiql.ast.Statement; import java.util.ArrayList; import java.util.List; @@ -17,7 +18,7 @@ */ @Builder(builderClassName = "Builder") @EqualsAndHashCode(callSuper = false) -public final class CreateTable extends Ddl { +public final class CreateTable extends Statement { @NotNull @Getter diff --git a/partiql-ast/src/main/java/org/partiql/ast/ddl/Ddl.java b/partiql-ast/src/main/java/org/partiql/ast/ddl/Ddl.java deleted file mode 100644 index ded6f073d..000000000 --- a/partiql-ast/src/main/java/org/partiql/ast/ddl/Ddl.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.partiql.ast.ddl; - -import org.partiql.ast.Statement; - -/** - * TODO docs, equals, hashcode - */ -public abstract class Ddl extends Statement { -} diff --git a/partiql-ast/src/main/java/org/partiql/ast/sql/SqlDialect.kt b/partiql-ast/src/main/java/org/partiql/ast/sql/SqlDialect.kt index baf88c260..c36ca4edf 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/sql/SqlDialect.kt +++ b/partiql-ast/src/main/java/org/partiql/ast/sql/SqlDialect.kt @@ -48,7 +48,7 @@ import org.partiql.ast.SetOp import org.partiql.ast.SetOpType import org.partiql.ast.SetQuantifier import org.partiql.ast.Sort -import org.partiql.ast.ddl.Ddl +import org.partiql.ast.ddl.CreateTable import org.partiql.ast.dml.Delete import org.partiql.ast.dml.Insert import org.partiql.ast.dml.Replace @@ -822,8 +822,8 @@ public abstract class SqlDialect : AstVisitor() { } // TODO: DDL - override fun visitDdl(node: Ddl, ctx: SqlBlock): SqlBlock { - throw UnsupportedOperationException("DDL has not been supported yet in SqlDialect") + override fun visitCreateTable(node: CreateTable, ctx: SqlBlock): SqlBlock { + throw UnsupportedOperationException("CREATE TABLE has not been supported yet in SqlDialect") } override fun visitInsert(node: Insert?, ctx: SqlBlock?): SqlBlock { 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 d51dbff8c..d801a847e 100644 --- a/partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt +++ b/partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt @@ -4,7 +4,7 @@ import org.partiql.ast.Ast.explain import org.partiql.ast.Ast.exprQuerySet import org.partiql.ast.Ast.identifier import org.partiql.ast.Ast.query -import org.partiql.ast.ddl.Ddl +import org.partiql.ast.ddl.CreateTable import org.partiql.ast.dml.ConflictAction import org.partiql.ast.dml.ConflictTarget import org.partiql.ast.dml.Delete @@ -802,8 +802,8 @@ public abstract class AstRewriter : AstVisitor() { } // TODO: DDL - override fun visitDdl(node: Ddl, ctx: C): AstNode { - throw UnsupportedOperationException("DDL has not been supported yet in AstRewriter") + override fun visitCreateTable(node: CreateTable?, ctx: C): AstNode { + throw UnsupportedOperationException("CREATE TABLE has not been supported yet in AstRewriter") } override fun visitInsert(node: Insert, ctx: C): AstNode {