Skip to content

Commit

Permalink
[v1] Remove UNKNOWN AST enum variant (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 authored Dec 24, 2024
1 parent b0403e6 commit ea779ee
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 262 deletions.
34 changes: 1 addition & 33 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ public class org/partiql/ast/DataType : org/partiql/ast/AstEnum {
public static final field TIME_WITH_TIME_ZONE I
public static final field TINYINT I
public static final field TUPLE I
public static final field UNKNOWN I
public static final field USER_DEFINED I
public static final field VARCHAR I
public static fun ARRAY ()Lorg/partiql/ast/DataType;
Expand Down Expand Up @@ -704,7 +703,6 @@ public class org/partiql/ast/DataType : org/partiql/ast/AstEnum {
public static fun TIME_WITH_TIME_ZONE (I)Lorg/partiql/ast/DataType;
public static fun TINYINT ()Lorg/partiql/ast/DataType;
public static fun TUPLE ()Lorg/partiql/ast/DataType;
public static fun UNKNOWN ()Lorg/partiql/ast/DataType;
public static fun USER_DEFINED ()Lorg/partiql/ast/DataType;
public static fun USER_DEFINED (Lorg/partiql/ast/IdentifierChain;)Lorg/partiql/ast/DataType;
public static fun VARCHAR ()Lorg/partiql/ast/DataType;
Expand Down Expand Up @@ -748,7 +746,6 @@ public class org/partiql/ast/DatetimeField : org/partiql/ast/AstEnum {
public static final field SECOND I
public static final field TIMEZONE_HOUR I
public static final field TIMEZONE_MINUTE I
public static final field UNKNOWN I
public static final field YEAR I
public static fun DAY ()Lorg/partiql/ast/DatetimeField;
public static fun HOUR ()Lorg/partiql/ast/DatetimeField;
Expand All @@ -757,7 +754,6 @@ public class org/partiql/ast/DatetimeField : org/partiql/ast/AstEnum {
public static fun SECOND ()Lorg/partiql/ast/DatetimeField;
public static fun TIMEZONE_HOUR ()Lorg/partiql/ast/DatetimeField;
public static fun TIMEZONE_MINUTE ()Lorg/partiql/ast/DatetimeField;
public static fun UNKNOWN ()Lorg/partiql/ast/DatetimeField;
public static fun YEAR ()Lorg/partiql/ast/DatetimeField;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
Expand Down Expand Up @@ -962,10 +958,8 @@ public abstract class org/partiql/ast/FromTableRef : org/partiql/ast/AstNode {

public class org/partiql/ast/FromType : org/partiql/ast/AstEnum {
public static final field SCAN I
public static final field UNKNOWN I
public static final field UNPIVOT I
public static fun SCAN ()Lorg/partiql/ast/FromType;
public static fun UNKNOWN ()Lorg/partiql/ast/FromType;
public static fun UNPIVOT ()Lorg/partiql/ast/FromType;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
Expand Down Expand Up @@ -1021,10 +1015,8 @@ public class org/partiql/ast/GroupBy$Key$Builder {
public class org/partiql/ast/GroupByStrategy : org/partiql/ast/AstEnum {
public static final field FULL I
public static final field PARTIAL I
public static final field UNKNOWN I
public static fun FULL ()Lorg/partiql/ast/GroupByStrategy;
public static fun PARTIAL ()Lorg/partiql/ast/GroupByStrategy;
public static fun UNKNOWN ()Lorg/partiql/ast/GroupByStrategy;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down Expand Up @@ -1084,7 +1076,6 @@ public class org/partiql/ast/JoinType : org/partiql/ast/AstEnum {
public static final field LEFT_OUTER I
public static final field RIGHT I
public static final field RIGHT_OUTER I
public static final field UNKNOWN I
public static fun CROSS ()Lorg/partiql/ast/JoinType;
public static fun FULL ()Lorg/partiql/ast/JoinType;
public static fun FULL_OUTER ()Lorg/partiql/ast/JoinType;
Expand All @@ -1094,7 +1085,6 @@ public class org/partiql/ast/JoinType : org/partiql/ast/AstEnum {
public static fun LEFT_OUTER ()Lorg/partiql/ast/JoinType;
public static fun RIGHT ()Lorg/partiql/ast/JoinType;
public static fun RIGHT_OUTER ()Lorg/partiql/ast/JoinType;
public static fun UNKNOWN ()Lorg/partiql/ast/JoinType;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down Expand Up @@ -1151,7 +1141,6 @@ public class org/partiql/ast/Literal : org/partiql/ast/AstEnum {
public static final field NULL I
public static final field STRING I
public static final field TYPED_STRING I
public static final field UNKNOWN I
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
public static fun approxNum (Ljava/lang/String;)Lorg/partiql/ast/Literal;
public fun bigDecimalValue ()Ljava/math/BigDecimal;
Expand Down Expand Up @@ -1181,10 +1170,8 @@ public class org/partiql/ast/Literal : org/partiql/ast/AstEnum {
public class org/partiql/ast/Nulls : org/partiql/ast/AstEnum {
public static final field FIRST I
public static final field LAST I
public static final field UNKNOWN I
public static fun FIRST ()Lorg/partiql/ast/Nulls;
public static fun LAST ()Lorg/partiql/ast/Nulls;
public static fun UNKNOWN ()Lorg/partiql/ast/Nulls;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand All @@ -1199,10 +1186,8 @@ public class org/partiql/ast/Nulls : org/partiql/ast/AstEnum {
public class org/partiql/ast/Order : org/partiql/ast/AstEnum {
public static final field ASC I
public static final field DESC I
public static final field UNKNOWN I
public static fun ASC ()Lorg/partiql/ast/Order;
public static fun DESC ()Lorg/partiql/ast/Order;
public static fun UNKNOWN ()Lorg/partiql/ast/Order;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down Expand Up @@ -1445,11 +1430,9 @@ public class org/partiql/ast/SetOpType : org/partiql/ast/AstEnum {
public static final field EXCEPT I
public static final field INTERSECT I
public static final field UNION I
public static final field UNKNOWN I
public static fun EXCEPT ()Lorg/partiql/ast/SetOpType;
public static fun INTERSECT ()Lorg/partiql/ast/SetOpType;
public static fun UNION ()Lorg/partiql/ast/SetOpType;
public static fun UNKNOWN ()Lorg/partiql/ast/SetOpType;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand All @@ -1464,10 +1447,8 @@ public class org/partiql/ast/SetOpType : org/partiql/ast/AstEnum {
public class org/partiql/ast/SetQuantifier : org/partiql/ast/AstEnum {
public static final field ALL I
public static final field DISTINCT I
public static final field UNKNOWN I
public static fun ALL ()Lorg/partiql/ast/SetQuantifier;
public static fun DISTINCT ()Lorg/partiql/ast/SetQuantifier;
public static fun UNKNOWN ()Lorg/partiql/ast/SetQuantifier;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down Expand Up @@ -2784,10 +2765,8 @@ public class org/partiql/ast/expr/PathStep$Field : org/partiql/ast/expr/PathStep
public class org/partiql/ast/expr/Scope : org/partiql/ast/AstEnum {
public static final field DEFAULT I
public static final field LOCAL I
public static final field UNKNOWN I
public static fun DEFAULT ()Lorg/partiql/ast/expr/Scope;
public static fun LOCAL ()Lorg/partiql/ast/expr/Scope;
public static fun UNKNOWN ()Lorg/partiql/ast/expr/Scope;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand All @@ -2802,11 +2781,9 @@ public class org/partiql/ast/expr/Scope : org/partiql/ast/AstEnum {
public class org/partiql/ast/expr/SessionAttribute : org/partiql/ast/AstEnum {
public static final field CURRENT_DATE I
public static final field CURRENT_USER I
public static final field UNKNOWN I
public fun <init> (I)V
public static fun CURRENT_DATE ()Lorg/partiql/ast/expr/SessionAttribute;
public static fun CURRENT_USER ()Lorg/partiql/ast/expr/SessionAttribute;
public static fun UNKNOWN ()Lorg/partiql/ast/expr/SessionAttribute;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand All @@ -2822,11 +2799,9 @@ public class org/partiql/ast/expr/TrimSpec : org/partiql/ast/AstEnum {
public static final field BOTH I
public static final field LEADING I
public static final field TRAILING I
public static final field UNKNOWN I
public static fun BOTH ()Lorg/partiql/ast/expr/TrimSpec;
public static fun LEADING ()Lorg/partiql/ast/expr/TrimSpec;
public static fun TRAILING ()Lorg/partiql/ast/expr/TrimSpec;
public static fun UNKNOWN ()Lorg/partiql/ast/expr/TrimSpec;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand All @@ -2841,12 +2816,10 @@ public class org/partiql/ast/expr/TrimSpec : org/partiql/ast/AstEnum {
public class org/partiql/ast/expr/TruthValue : org/partiql/ast/AstEnum {
public static final field FALSE I
public static final field TRUE I
public static final field UNK I
public static final field UNKNOWN I
public fun <init> (I)V
public static fun FALSE ()Lorg/partiql/ast/expr/TruthValue;
public static fun TRUE ()Lorg/partiql/ast/expr/TruthValue;
public static fun UNK ()Lorg/partiql/ast/expr/TruthValue;
public static fun UNKNOWN ()Lorg/partiql/ast/expr/TruthValue;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
Expand All @@ -2855,16 +2828,15 @@ public class org/partiql/ast/expr/TruthValue : org/partiql/ast/AstEnum {
public fun getChildren ()Ljava/util/List;
public fun hashCode ()I
public fun name ()Ljava/lang/String;
public static fun parse (Ljava/lang/String;)Lorg/partiql/ast/expr/TruthValue;
}

public class org/partiql/ast/expr/WindowFunction : org/partiql/ast/AstEnum {
public static final field LAG I
public static final field LEAD I
public static final field UNKNOWN I
public fun <init> (I)V
public static fun LAG ()Lorg/partiql/ast/expr/WindowFunction;
public static fun LEAD ()Lorg/partiql/ast/expr/WindowFunction;
public static fun UNKNOWN ()Lorg/partiql/ast/expr/WindowFunction;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand All @@ -2884,15 +2856,13 @@ public class org/partiql/ast/graph/GraphDirection : org/partiql/ast/AstEnum {
public static final field RIGHT I
public static final field UNDIRECTED I
public static final field UNDIRECTED_OR_RIGHT I
public static final field UNKNOWN I
public static fun LEFT ()Lorg/partiql/ast/graph/GraphDirection;
public static fun LEFT_OR_RIGHT ()Lorg/partiql/ast/graph/GraphDirection;
public static fun LEFT_OR_UNDIRECTED ()Lorg/partiql/ast/graph/GraphDirection;
public static fun LEFT_UNDIRECTED_OR_RIGHT ()Lorg/partiql/ast/graph/GraphDirection;
public static fun RIGHT ()Lorg/partiql/ast/graph/GraphDirection;
public static fun UNDIRECTED ()Lorg/partiql/ast/graph/GraphDirection;
public static fun UNDIRECTED_OR_RIGHT ()Lorg/partiql/ast/graph/GraphDirection;
public static fun UNKNOWN ()Lorg/partiql/ast/graph/GraphDirection;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down Expand Up @@ -3129,11 +3099,9 @@ public class org/partiql/ast/graph/GraphRestrictor : org/partiql/ast/AstEnum {
public static final field ACYCLIC I
public static final field SIMPLE I
public static final field TRAIL I
public static final field UNKNOWN I
public static fun ACYCLIC ()Lorg/partiql/ast/graph/GraphRestrictor;
public static fun SIMPLE ()Lorg/partiql/ast/graph/GraphRestrictor;
public static fun TRAIL ()Lorg/partiql/ast/graph/GraphRestrictor;
public static fun UNKNOWN ()Lorg/partiql/ast/graph/GraphRestrictor;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down
101 changes: 48 additions & 53 deletions partiql-ast/src/main/java/org/partiql/ast/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,68 +68,63 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
}
}

public static final int UNKNOWN = 0;
// <character string type>
public static final int CHARACTER = 1;
public static final int CHAR = 2;
public static final int CHARACTER_VARYING = 3;
public static final int CHAR_VARYING = 4; // TODO not defined in parser yet
public static final int VARCHAR = 5;
public static final int CHARACTER_LARGE_OBJECT = 6; // TODO not defined in parser yet
public static final int CHAR_LARGE_OBJECT = 7; // TODO not defined in parser yet
public static final int CLOB = 8;
public static final int STRING = 9;
public static final int SYMBOL = 10;
public static final int CHARACTER = 0;
public static final int CHAR = 1;
public static final int CHARACTER_VARYING = 2;
public static final int CHAR_VARYING = 3; // TODO not defined in parser yet
public static final int VARCHAR = 4;
public static final int CHARACTER_LARGE_OBJECT = 5; // TODO not defined in parser yet
public static final int CHAR_LARGE_OBJECT = 6; // TODO not defined in parser yet
public static final int CLOB = 7;
public static final int STRING = 8;
public static final int SYMBOL = 9;
// <binary large object string type>
public static final int BLOB = 11;
public static final int BINARY_LARGE_OBJECT = 12; // TODO not defined in parser yet
public static final int BLOB = 10;
public static final int BINARY_LARGE_OBJECT = 11; // TODO not defined in parser yet
// <bit string type>
public static final int BIT = 13; // TODO not defined in parser yet
public static final int BIT_VARYING = 14; // TODO not defined in parser yet
public static final int BIT = 12; // TODO not defined in parser yet
public static final int BIT_VARYING = 13; // TODO not defined in parser yet
// <numeric type> - <exact numeric type>
public static final int NUMERIC = 15;
public static final int DECIMAL = 16;
public static final int DEC = 17;
public static final int BIGINT = 18;
public static final int INT8 = 19;
public static final int INTEGER8 = 20;
public static final int INT4 = 21;
public static final int INTEGER4 = 22;
public static final int INTEGER = 23;
public static final int INT = 24;
public static final int INT2 = 25;
public static final int INTEGER2 = 26;
public static final int SMALLINT = 27;
public static final int TINYINT = 28; // TODO not defined in parser yet
public static final int NUMERIC = 14;
public static final int DECIMAL = 15;
public static final int DEC = 16;
public static final int BIGINT = 17;
public static final int INT8 = 18;
public static final int INTEGER8 = 19;
public static final int INT4 = 20;
public static final int INTEGER4 = 21;
public static final int INTEGER = 22;
public static final int INT = 23;
public static final int INT2 = 24;
public static final int INTEGER2 = 25;
public static final int SMALLINT = 26;
public static final int TINYINT = 27; // TODO not defined in parser yet
// <numeric type> - <approximate numeric type>
public static final int FLOAT = 29;
public static final int REAL = 30;
public static final int DOUBLE_PRECISION = 31;
public static final int FLOAT = 28;
public static final int REAL = 29;
public static final int DOUBLE_PRECISION = 30;
// <boolean type>
public static final int BOOLEAN = 32;
public static final int BOOL = 33;
public static final int BOOLEAN = 31;
public static final int BOOL = 32;
// <datetime type>
public static final int DATE = 34;
public static final int TIME = 35;
public static final int TIME_WITH_TIME_ZONE = 36;
public static final int TIMESTAMP = 37;
public static final int TIMESTAMP_WITH_TIME_ZONE = 38;
public static final int DATE = 33;
public static final int TIME = 34;
public static final int TIME_WITH_TIME_ZONE = 35;
public static final int TIMESTAMP = 36;
public static final int TIMESTAMP_WITH_TIME_ZONE = 37;
// <interval type>
public static final int INTERVAL = 39; // TODO not defined in parser yet
public static final int INTERVAL = 38; // TODO not defined in parser yet
// <container type>
public static final int STRUCT = 40;
public static final int TUPLE = 41;
public static final int STRUCT = 39;
public static final int TUPLE = 40;
// <collection type>
public static final int LIST = 42;
public static final int ARRAY = 43;
public static final int BAG = 44;
public static final int SEXP = 45;
public static final int LIST = 41;
public static final int ARRAY = 42;
public static final int BAG = 43;
public static final int SEXP = 44;
// <user defined type>
public static final int USER_DEFINED = 46;

public static DataType UNKNOWN() {
return new DataType(UNKNOWN);
}
public static final int USER_DEFINED = 45;

public static DataType BOOL() {
return new DataType(BOOL);
Expand Down Expand Up @@ -541,7 +536,7 @@ public String name() {
case BAG: return "BAG";
case SEXP: return "SEXP";
case USER_DEFINED: return "USER_DEFINED";
default: return "UNKNOWN";
default: throw new IllegalStateException("Invalid DataType code: " + code);
}
}

Expand Down Expand Up @@ -643,7 +638,7 @@ public static DataType parse(@NotNull String value) {
case "TIMESTAMP_WITH_TIME_ZONE": return TIMESTAMP_WITH_TIME_ZONE();
case "INTERVAL": return INTERVAL();
case "USER_DEFINED": return USER_DEFINED();
default: return UNKNOWN();
default: throw new IllegalArgumentException("No enum constant DataType." + value);
}
}

Expand Down
25 changes: 10 additions & 15 deletions partiql-ast/src/main/java/org/partiql/ast/DatetimeField.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@
*/
@EqualsAndHashCode(callSuper = false)
public class DatetimeField extends AstEnum {
public static final int UNKNOWN = 0;
public static final int YEAR = 1;
public static final int MONTH = 2;
public static final int DAY = 3;
public static final int HOUR = 4;
public static final int MINUTE = 5;
public static final int SECOND = 6;
public static final int TIMEZONE_HOUR = 7;
public static final int TIMEZONE_MINUTE = 8;

public static DatetimeField UNKNOWN() {
return new DatetimeField(UNKNOWN);
}
public static final int YEAR = 0;
public static final int MONTH = 1;
public static final int DAY = 2;
public static final int HOUR = 3;
public static final int MINUTE = 4;
public static final int SECOND = 5;
public static final int TIMEZONE_HOUR = 6;
public static final int TIMEZONE_MINUTE = 7;

public static DatetimeField YEAR() {
return new DatetimeField(YEAR);
Expand Down Expand Up @@ -80,7 +75,7 @@ public String name() {
case SECOND: return "SECOND";
case TIMEZONE_HOUR: return "TIMEZONE_HOUR";
case TIMEZONE_MINUTE: return "TIMEZONE_MINUTE";
default: return "UNKNOWN";
default: throw new IllegalStateException("Invalid DatetimeField code: " + code);
}
}

Expand All @@ -107,7 +102,7 @@ public static DatetimeField parse(@NotNull String value) {
case "SECOND": return SECOND();
case "TIMEZONE_HOUR": return TIMEZONE_HOUR();
case "TIMEZONE_MINUTE": return TIMEZONE_MINUTE();
default: return UNKNOWN();
default: throw new IllegalArgumentException("No enum constant DatetimeField." + value);
}
}

Expand Down
Loading

0 comments on commit ea779ee

Please sign in to comment.