From 252603a9fa71f83955350668b399691707ab5b0c Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Fri, 4 Oct 2024 12:40:06 -0700 Subject: [PATCH] Address Robert's feedback; refactor naming, DataType order, add some TODOs --- partiql-ast/api/partiql-ast.api | 64 ++++---- .../main/java/org/partiql/ast/v1/AstNode.java | 1 + .../java/org/partiql/ast/v1/AstVisitor.java | 8 +- .../java/org/partiql/ast/v1/DataType.java | 150 +++++++++++++----- .../main/java/org/partiql/ast/v1/Explain.java | 15 +- .../main/java/org/partiql/ast/v1/From.java | 4 +- .../ast/v1/{FromValue.java => FromExpr.java} | 8 +- .../java/org/partiql/ast/v1/ProjectItem.java | 23 ++- .../main/java/org/partiql/ast/v1/Target.java | 55 ------- .../java/org/partiql/ast/v1/expr/ExprLit.java | 2 +- 10 files changed, 170 insertions(+), 160 deletions(-) rename partiql-ast/src/main/java/org/partiql/ast/v1/{FromValue.java => FromExpr.java} (80%) delete mode 100644 partiql-ast/src/main/java/org/partiql/ast/v1/Target.java diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index adb39b30a8..5c44d2dece 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -5597,8 +5597,8 @@ public abstract interface class org/partiql/ast/v1/AstVisitor { public abstract fun visitExprWindow (Lorg/partiql/ast/v1/expr/ExprWindow;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitExprWindowOver (Lorg/partiql/ast/v1/expr/ExprWindow$Over;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitFrom (Lorg/partiql/ast/v1/From;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitFromExpr (Lorg/partiql/ast/v1/FromExpr;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitFromJoin (Lorg/partiql/ast/v1/FromJoin;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitFromValue (Lorg/partiql/ast/v1/FromValue;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitGraphLabel (Lorg/partiql/ast/v1/graph/GraphLabel;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitGraphLabelConj (Lorg/partiql/ast/v1/graph/GraphLabel$Conj;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitGraphLabelDisj (Lorg/partiql/ast/v1/graph/GraphLabel$Disj;Ljava/lang/Object;)Ljava/lang/Object; @@ -5633,7 +5633,7 @@ public abstract interface class org/partiql/ast/v1/AstVisitor { public abstract fun visitPathStepField (Lorg/partiql/ast/v1/expr/PathStep$Field;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitProjectItem (Lorg/partiql/ast/v1/ProjectItem;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitProjectItemAll (Lorg/partiql/ast/v1/ProjectItem$All;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitProjectItemExpression (Lorg/partiql/ast/v1/ProjectItem$Expression;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun visitProjectItemExpr (Lorg/partiql/ast/v1/ProjectItem$Expr;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitQuery (Lorg/partiql/ast/v1/Query;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitQueryBody (Lorg/partiql/ast/v1/QueryBody;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitQueryBodySFW (Lorg/partiql/ast/v1/QueryBody$SFW;Ljava/lang/Object;)Ljava/lang/Object; @@ -5646,13 +5646,12 @@ public abstract interface class org/partiql/ast/v1/AstVisitor { public abstract fun visitSetOp (Lorg/partiql/ast/v1/SetOp;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitSort (Lorg/partiql/ast/v1/Sort;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun visitStatement (Lorg/partiql/ast/v1/Statement;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitTarget (Lorg/partiql/ast/v1/Target;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun visitTargetDomain (Lorg/partiql/ast/v1/Target$Domain;Ljava/lang/Object;)Ljava/lang/Object; } public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public static final field BAG I public static final field BIGINT I + public static final field BINARY_LARGE_OBJECT I public static final field BIT I public static final field BIT_VARYING I public static final field BLOB I @@ -5660,7 +5659,10 @@ public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public static final field BOOLEAN I public static final field CHAR I public static final field CHARACTER I + public static final field CHARACTER_LARGE_OBJECT I public static final field CHARACTER_VARYING I + public static final field CHAR_LARGE_OBJECT I + public static final field CHAR_VARYING I public static final field CLOB I public static final field DATE I public static final field DEC I @@ -5697,6 +5699,8 @@ public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public static final field VARCHAR I public static fun BAG ()Lorg/partiql/ast/v1/DataType; public static fun BIGINT ()Lorg/partiql/ast/v1/DataType; + public static fun BINARY_LARGE_OBJECT ()Lorg/partiql/ast/v1/DataType; + public static fun BINARY_LARGE_OBJECT (I)Lorg/partiql/ast/v1/DataType; public static fun BIT ()Lorg/partiql/ast/v1/DataType; public static fun BIT (I)Lorg/partiql/ast/v1/DataType; public static fun BIT_VARYING ()Lorg/partiql/ast/v1/DataType; @@ -5709,8 +5713,14 @@ public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public static fun CHAR (I)Lorg/partiql/ast/v1/DataType; public static fun CHARACTER ()Lorg/partiql/ast/v1/DataType; public static fun CHARACTER (I)Lorg/partiql/ast/v1/DataType; + public static fun CHARACTER_LARGE_OBJECT ()Lorg/partiql/ast/v1/DataType; + public static fun CHARACTER_LARGE_OBJECT (I)Lorg/partiql/ast/v1/DataType; public static fun CHARACTER_VARYING ()Lorg/partiql/ast/v1/DataType; public static fun CHARACTER_VARYING (I)Lorg/partiql/ast/v1/DataType; + public static fun CHAR_LARGE_OBJECT ()Lorg/partiql/ast/v1/DataType; + public static fun CHAR_LARGE_OBJECT (I)Lorg/partiql/ast/v1/DataType; + public static fun CHAR_VARYING ()Lorg/partiql/ast/v1/DataType; + public static fun CHAR_VARYING (I)Lorg/partiql/ast/v1/DataType; public static fun CLOB ()Lorg/partiql/ast/v1/DataType; public static fun CLOB (I)Lorg/partiql/ast/v1/DataType; public static fun DATE ()Lorg/partiql/ast/v1/DataType; @@ -5720,6 +5730,7 @@ public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public static fun DECIMAL (II)Lorg/partiql/ast/v1/DataType; public static fun DOUBLE_PRECISION ()Lorg/partiql/ast/v1/DataType; public static fun FLOAT ()Lorg/partiql/ast/v1/DataType; + public static fun FLOAT (I)Lorg/partiql/ast/v1/DataType; public static fun INT ()Lorg/partiql/ast/v1/DataType; public static fun INT2 ()Lorg/partiql/ast/v1/DataType; public static fun INT4 ()Lorg/partiql/ast/v1/DataType; @@ -5753,7 +5764,7 @@ public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public static fun TINYINT ()Lorg/partiql/ast/v1/DataType; public static fun TUPLE ()Lorg/partiql/ast/v1/DataType; public static fun UNKNOWN ()Lorg/partiql/ast/v1/DataType; - public static fun USER_DEFINED ()Lorg/partiql/ast/v1/DataType; + public static fun USER_DEFINED (Lorg/partiql/ast/v1/IdentifierChain;)Lorg/partiql/ast/v1/DataType; public static fun VARCHAR ()Lorg/partiql/ast/v1/DataType; public static fun VARCHAR (I)Lorg/partiql/ast/v1/DataType; public fun code ()I @@ -5831,8 +5842,9 @@ public class org/partiql/ast/v1/ExcludeStep$StructWildcard : org/partiql/ast/v1/ } public class org/partiql/ast/v1/Explain : org/partiql/ast/v1/Statement { - public field target Lorg/partiql/ast/v1/Target; - public fun (Lorg/partiql/ast/v1/Target;)V + public field options Ljava/util/Map; + public field statement Lorg/partiql/ast/v1/Statement; + public fun (Ljava/util/Map;Lorg/partiql/ast/v1/Statement;)V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; public fun children ()Ljava/util/Collection; } @@ -5842,6 +5854,17 @@ public abstract class org/partiql/ast/v1/From : org/partiql/ast/v1/AstNode { public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; } +public class org/partiql/ast/v1/FromExpr : org/partiql/ast/v1/From { + public field asAlias Lorg/partiql/ast/v1/Identifier; + public field atAlias Lorg/partiql/ast/v1/Identifier; + public field byAlias Lorg/partiql/ast/v1/Identifier; + public field expr Lorg/partiql/ast/v1/expr/Expr; + public field fromType Lorg/partiql/ast/v1/FromType; + public fun (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/FromType;Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/Identifier;)V + public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; + public fun children ()Ljava/util/Collection; +} + public class org/partiql/ast/v1/FromJoin : org/partiql/ast/v1/From { public field condition Lorg/partiql/ast/v1/expr/Expr; public field joinType Lorg/partiql/ast/v1/JoinType; @@ -5862,17 +5885,6 @@ public class org/partiql/ast/v1/FromType : org/partiql/ast/v1/Enum { public fun code ()I } -public class org/partiql/ast/v1/FromValue : org/partiql/ast/v1/From { - public field asAlias Lorg/partiql/ast/v1/Identifier; - public field atAlias Lorg/partiql/ast/v1/Identifier; - public field byAlias Lorg/partiql/ast/v1/Identifier; - public field expr Lorg/partiql/ast/v1/expr/Expr; - public field fromType Lorg/partiql/ast/v1/FromType; - public fun (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/FromType;Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/Identifier;Lorg/partiql/ast/v1/Identifier;)V - public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public fun children ()Ljava/util/Collection; -} - public class org/partiql/ast/v1/GroupBy : org/partiql/ast/v1/AstNode { public field asAlias Lorg/partiql/ast/v1/Identifier; public field keys Ljava/util/List; @@ -5994,7 +6006,7 @@ public class org/partiql/ast/v1/ProjectItem$All : org/partiql/ast/v1/ProjectItem public fun children ()Ljava/util/Collection; } -public class org/partiql/ast/v1/ProjectItem$Expression : org/partiql/ast/v1/ProjectItem { +public class org/partiql/ast/v1/ProjectItem$Expr : org/partiql/ast/v1/ProjectItem { public field asAlias Lorg/partiql/ast/v1/Identifier; public field expr Lorg/partiql/ast/v1/expr/Expr; public fun (Lorg/partiql/ast/v1/expr/Expr;Lorg/partiql/ast/v1/Identifier;)V @@ -6112,20 +6124,6 @@ public abstract class org/partiql/ast/v1/Statement : org/partiql/ast/v1/AstNode public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; } -public abstract class org/partiql/ast/v1/Target : org/partiql/ast/v1/AstNode { - public fun ()V - public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; -} - -public class org/partiql/ast/v1/Target$Domain : org/partiql/ast/v1/Target { - public field format Ljava/lang/String; - public field statement Lorg/partiql/ast/v1/Statement; - public field type Ljava/lang/String; - public fun (Lorg/partiql/ast/v1/Statement;Ljava/lang/String;Ljava/lang/String;)V - public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; - public fun children ()Ljava/util/Collection; -} - public abstract class org/partiql/ast/v1/expr/Expr : org/partiql/ast/v1/AstNode { public fun ()V public fun accept (Lorg/partiql/ast/v1/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object; diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/AstNode.java b/partiql-ast/src/main/java/org/partiql/ast/v1/AstNode.java index 232ca783f6..c192ae9e0c 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/AstNode.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/AstNode.java @@ -7,6 +7,7 @@ /** * TODO docs, equals, hashcode + * TODO support source location -- https://github.com/partiql/partiql-lang-kotlin/issues/1608 */ public abstract class AstNode { @NotNull diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java b/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java index 422fc35d6e..ea7173cd9d 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java @@ -49,10 +49,6 @@ public interface AstVisitor { R visitExplain(Explain node, C ctx); - R visitTarget(Target node, C ctx); - - R visitTargetDomain(Target.Domain node, C ctx); - R visitIdentifier(Identifier node, C ctx); R visitIdentifierChain(IdentifierChain node, C ctx); @@ -155,7 +151,7 @@ public interface AstVisitor { R visitProjectItemAll(ProjectItem.All node, C ctx); - R visitProjectItemExpression(ProjectItem.Expression node, C ctx); + R visitProjectItemExpr(ProjectItem.Expr node, C ctx); R visitSelectPivot(SelectPivot node, C ctx); @@ -177,7 +173,7 @@ public interface AstVisitor { R visitFrom(From node, C ctx); - R visitFromValue(FromValue node, C ctx); + R visitFromExpr(FromExpr node, C ctx); R visitFromJoin(FromJoin node, C ctx); diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/DataType.java b/partiql-ast/src/main/java/org/partiql/ast/v1/DataType.java index 9610afdef7..c0f632524d 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/DataType.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/DataType.java @@ -2,49 +2,65 @@ public class DataType implements Enum { public static final int UNKNOWN = 0; + // public static final int NULL = 1; public static final int MISSING = 2; - public static final int BOOL = 3; - public static final int BOOLEAN = 4; - public static final int TINYINT = 5; // TODO not defined in parser yet - public static final int SMALLINT = 6; - public static final int INTEGER2 = 7; - public static final int INT2 = 8; - public static final int INTEGER = 9; - public static final int INT = 10; - public static final int INTEGER4 = 11; - public static final int INT4 = 12; - public static final int INTEGER8 = 13; - public static final int INT8 = 14; - public static final int BIGINT = 15; - public static final int REAL = 16; - public static final int DOUBLE_PRECISION = 17; - public static final int FLOAT = 18; - public static final int DECIMAL = 19; - public static final int DEC = 20; - public static final int NUMERIC = 21; - public static final int BIT = 22; // TODO not defined in parser yet - public static final int BIT_VARYING = 23; // TODO not defined in parser yet - public static final int CHAR = 24; - public static final int CHARACTER = 25; - public static final int VARCHAR = 26; - public static final int CHARACTER_VARYING = 27; - public static final int STRING = 28; - public static final int SYMBOL = 29; - public static final int BLOB = 30; - public static final int CLOB = 31; - public static final int DATE = 32; - public static final int STRUCT = 33; - public static final int TUPLE = 34; - public static final int LIST = 35; - public static final int SEXP = 36; - public static final int BAG = 37; - public static final int TIME = 38; + // + public static final int CHARACTER = 3; + public static final int CHAR = 4; + public static final int CHARACTER_VARYING = 5; + public static final int CHAR_VARYING = 6; // TODO not defined in parser yet + public static final int VARCHAR = 7; + public static final int CHARACTER_LARGE_OBJECT = 8; // TODO not defined in parser yet + public static final int CHAR_LARGE_OBJECT = 9; // TODO not defined in parser yet + public static final int CLOB = 10; + public static final int STRING = 11; + public static final int SYMBOL = 12; + // + public static final int BLOB = 13; + public static final int BINARY_LARGE_OBJECT = 14; // TODO not defined in parser yet + // + public static final int BIT = 15; // TODO not defined in parser yet + public static final int BIT_VARYING = 16; // TODO not defined in parser yet + // - + public static final int NUMERIC = 17; + public static final int DECIMAL = 18; + public static final int DEC = 19; + public static final int BIGINT = 20; + public static final int INT8 = 21; + public static final int INTEGER8 = 22; + public static final int INT4 = 23; + public static final int INTEGER4 = 24; + public static final int INTEGER = 25; + public static final int INT = 26; + public static final int INT2 = 27; + public static final int INTEGER2 = 28; + public static final int SMALLINT = 29; + public static final int TINYINT = 30; // TODO not defined in parser yet + // - + public static final int FLOAT = 31; + public static final int REAL = 32; + public static final int DOUBLE_PRECISION = 33; + // + public static final int BOOLEAN = 34; + public static final int BOOL = 35; + // + public static final int DATE = 36; + public static final int TIME = 37; + public static final int TIME_WITH_TIME_ZONE = 38; public static final int TIMESTAMP = 39; - public static final int TIME_WITH_TIME_ZONE = 40; - public static final int TIMESTAMP_WITH_TIME_ZONE = 41; - public static final int INTERVAL = 42; // TODO not defined in parser yet - public static final int USER_DEFINED = 43; + public static final int TIMESTAMP_WITH_TIME_ZONE = 40; + // + public static final int INTERVAL = 41; // TODO not defined in parser yet + // + public static final int STRUCT = 42; + public static final int TUPLE = 43; + // + public static final int LIST = 44; + public static final int BAG = 45; + public static final int SEXP = 46; + // + public static final int USER_DEFINED = 47; public static DataType UNKNOWN() { return new DataType(UNKNOWN); @@ -122,6 +138,10 @@ public static DataType FLOAT() { return new DataType(FLOAT); } + public static DataType FLOAT(int precision) { + return new DataType(FLOAT, precision, null, null); + } + public static DataType DECIMAL() { return new DataType(DECIMAL); } @@ -190,10 +210,34 @@ public static DataType VARCHAR(int length) { return new DataType(VARCHAR, null, null, length); } + public static DataType CHARACTER_LARGE_OBJECT() { + return new DataType(CHARACTER_LARGE_OBJECT); + } + + public static DataType CHARACTER_LARGE_OBJECT(int length) { + return new DataType(CHARACTER_LARGE_OBJECT, null, null, length); + } + + public static DataType CHAR_LARGE_OBJECT() { + return new DataType(CHAR_LARGE_OBJECT); + } + + public static DataType CHAR_LARGE_OBJECT(int length) { + return new DataType(CHAR_LARGE_OBJECT, null, null, length); + } + public static DataType CHARACTER_VARYING() { return new DataType(CHARACTER_VARYING); } + public static DataType CHAR_VARYING() { + return new DataType(CHAR_VARYING); + } + + public static DataType CHAR_VARYING(int length) { + return new DataType(CHAR_VARYING, null, null, length); + } + public static DataType CHARACTER_VARYING(int length) { return new DataType(CHARACTER_VARYING, null, null, length); } @@ -218,6 +262,14 @@ public static DataType BLOB(int length) { return new DataType(BLOB, null, null, length); } + public static DataType BINARY_LARGE_OBJECT() { + return new DataType(BINARY_LARGE_OBJECT); + } + + public static DataType BINARY_LARGE_OBJECT(int length) { + return new DataType(BINARY_LARGE_OBJECT, null, null, length); + } + public static DataType CLOB() { return new DataType(CLOB); } @@ -286,14 +338,15 @@ public static DataType INTERVAL() { return new DataType(INTERVAL); } - public static DataType USER_DEFINED() { - return new DataType(USER_DEFINED); + public static DataType USER_DEFINED(IdentifierChain name) { + return new DataType(USER_DEFINED, name); } private final int code; private final Integer precision; private final Integer scale; private final Integer length; + private final IdentifierChain name; // Private constructor for no parameter DataTypes private DataType(int code) { @@ -301,14 +354,25 @@ private DataType(int code) { this.precision = null; this.scale = null; this.length = null; + this.name = null; } - // Private constructor for DataTypes with parameters + // Private constructor for DataTypes with Integer parameters; set `name` to null private DataType(int code, Integer precision, Integer scale, Integer length) { this.code = code; this.precision = precision; this.scale = scale; this.length = length; + this.name = null; + } + + // Private constructor for user-defined type w/ an `IdentifierChain` `name`; other parameters set to null + private DataType(int code, IdentifierChain name) { + this.code = code; + this.name = name; + this.precision = null; + this.scale = null; + this.length = null; } @Override diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/Explain.java b/partiql-ast/src/main/java/org/partiql/ast/v1/Explain.java index eede3e764f..a89a1c40d7 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/Explain.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/Explain.java @@ -1,27 +1,34 @@ package org.partiql.ast.v1; import org.jetbrains.annotations.NotNull; +import org.partiql.value.PartiQLValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; /** * TODO docs, equals, hashcode */ public class Explain extends Statement { + // TODO get rid of PartiQLValue once https://github.com/partiql/partiql-lang-kotlin/issues/1589 is resolved @NotNull - public Target target; + public Map options; - public Explain(@NotNull Target target) { - this.target = target; + @NotNull + public Statement statement; + + public Explain(@NotNull Map options, @NotNull Statement statement) { + this.options = options; + this.statement = statement; } @NotNull @Override public Collection children() { List kids = new ArrayList<>(); - kids.add(target); + kids.add(statement); return kids; } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/From.java b/partiql-ast/src/main/java/org/partiql/ast/v1/From.java index f82a41da6b..92f43bb9c4 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/From.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/From.java @@ -8,8 +8,8 @@ public abstract class From extends AstNode { @Override public R accept(@NotNull AstVisitor visitor, C ctx) { - if (this instanceof FromValue) { - return visitor.visitFromValue((FromValue) this, ctx); + if (this instanceof FromExpr) { + return visitor.visitFromExpr((FromExpr) this, ctx); } else if (this instanceof FromJoin) { return visitor.visitFromJoin((FromJoin) this, ctx); } else { diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/FromValue.java b/partiql-ast/src/main/java/org/partiql/ast/v1/FromExpr.java similarity index 80% rename from partiql-ast/src/main/java/org/partiql/ast/v1/FromValue.java rename to partiql-ast/src/main/java/org/partiql/ast/v1/FromExpr.java index b7198b9ab8..e9f2ba9004 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/FromValue.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/FromExpr.java @@ -11,7 +11,7 @@ /** * TODO docs, equals, hashcode */ -public class FromValue extends From { +public class FromExpr extends From { @NotNull public Expr expr; @@ -30,8 +30,8 @@ public class FromValue extends From { @Nullable public Identifier byAlias; - public FromValue(@NotNull Expr expr, @NotNull FromType fromType, @Nullable Identifier asAlias, - @Nullable Identifier atAlias, @Nullable Identifier byAlias) { + public FromExpr(@NotNull Expr expr, @NotNull FromType fromType, @Nullable Identifier asAlias, + @Nullable Identifier atAlias, @Nullable Identifier byAlias) { this.expr = expr; this.fromType = fromType; this.asAlias = asAlias; @@ -52,6 +52,6 @@ public Collection children() { @Override public R accept(@NotNull AstVisitor visitor, C ctx) { - return visitor.visitFromValue(this, ctx); + return visitor.visitFromExpr(this, ctx); } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/ProjectItem.java b/partiql-ast/src/main/java/org/partiql/ast/v1/ProjectItem.java index d8cebe51d8..e3e8ad049f 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/ProjectItem.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/ProjectItem.java @@ -2,7 +2,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.partiql.ast.v1.expr.Expr; import java.util.ArrayList; import java.util.Collection; @@ -16,8 +15,8 @@ public abstract class ProjectItem extends AstNode { public R accept(@NotNull AstVisitor visitor, C ctx) { if (this instanceof All) { return visitor.visitProjectItemAll((All) this, ctx); - } else if (this instanceof Expression) { - return visitor.visitProjectItemExpression((Expression) this, ctx); + } else if (this instanceof Expr) { + return visitor.visitProjectItemExpr((Expr) this, ctx); } else { throw new IllegalStateException("Unexpected value: " + this); } @@ -28,9 +27,9 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { */ public static class All extends ProjectItem { @NotNull - public Expr expr; + public org.partiql.ast.v1.expr.Expr expr; - public All(@NotNull Expr expr) { + public All(@NotNull org.partiql.ast.v1.expr.Expr expr) { this.expr = expr; } @@ -51,17 +50,17 @@ public R accept(@NotNull AstVisitor visitor, C ctx) { /** * TODO docs, equals, hashcode */ - public static class Expression extends ProjectItem { + public static class Expr extends ProjectItem { @NotNull - public Expr expr; + public org.partiql.ast.v1.expr.Expr expr; @Nullable public Identifier asAlias; - public Expression(@NotNull Expr expr, @Nullable Identifier asAlias) { - this.expr = expr; - this.asAlias = asAlias; - } + public Expr(@NotNull org.partiql.ast.v1.expr.Expr expr, @Nullable Identifier asAlias) { + this.expr = expr; + this.asAlias = asAlias; + } @NotNull @Override @@ -76,7 +75,7 @@ public Collection children() { @Override public R accept(@NotNull AstVisitor visitor, C ctx) { - return visitor.visitProjectItemExpression(this, ctx); + return visitor.visitProjectItemExpr(this, ctx); } } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/Target.java b/partiql-ast/src/main/java/org/partiql/ast/v1/Target.java deleted file mode 100644 index 161457b291..0000000000 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/Target.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.partiql.ast.v1; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * TODO docs, equals, hashcode - */ -public abstract class Target extends AstNode { - @Override - public R accept(@NotNull AstVisitor visitor, C ctx) { - if (this instanceof Domain) { - return visitor.visitTargetDomain((Domain) this, ctx); - } else { - throw new IllegalStateException("Unexpected value: " + this); - } - } - - /** - * TODO docs, equals, hashcode - */ - public static class Domain extends Target { - @NotNull - public Statement statement; - - @Nullable - public String type; - - @Nullable - public String format; - - public Domain(@NotNull Statement statement, @Nullable String type, @Nullable String format) { - this.statement = statement; - this.type = type; - this.format = format; - } - - @NotNull - @Override - public Collection children() { - List kids = new ArrayList<>(); - kids.add(statement); - return kids; - } - - @Override - public R accept(@NotNull AstVisitor < R, C > visitor, C ctx) { - return visitor.visitTargetDomain(this, ctx); - } - } -} diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/ExprLit.java b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/ExprLit.java index d26d213acb..77d70cf04d 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/ExprLit.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/ExprLit.java @@ -13,7 +13,7 @@ */ public class ExprLit extends Expr { @NotNull - public PartiQLValue value; + public PartiQLValue value; // This representation be changed in https://github.com/partiql/partiql-lang-kotlin/issues/1589 public ExprLit(@NotNull PartiQLValue value) { this.value = value;