From bb30367981129a6c7a0c9d10d841394e902fe349 Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Tue, 22 Oct 2024 16:19:15 -0700 Subject: [PATCH] [v1] Add .valueOf and .values methods for enums --- partiql-ast/api/partiql-ast.api | 31 +++++ .../java/org/partiql/ast/v1/DataType.java | 110 +++++++++++++++++- .../org/partiql/ast/v1/DatetimeField.java | 27 +++++ .../java/org/partiql/ast/v1/FromType.java | 15 +++ .../org/partiql/ast/v1/GroupByStrategy.java | 15 +++ .../java/org/partiql/ast/v1/JoinType.java | 27 +++++ .../main/java/org/partiql/ast/v1/Nulls.java | 16 +++ .../main/java/org/partiql/ast/v1/Order.java | 15 +++ .../java/org/partiql/ast/v1/SetOpType.java | 18 +++ .../org/partiql/ast/v1/SetQuantifier.java | 17 ++- .../java/org/partiql/ast/v1/expr/Scope.java | 16 +++ .../partiql/ast/v1/expr/SessionAttribute.java | 15 +++ .../org/partiql/ast/v1/expr/TrimSpec.java | 17 +++ .../partiql/ast/v1/expr/WindowFunction.java | 15 +++ .../partiql/ast/v1/graph/GraphDirection.java | 25 ++++ .../partiql/ast/v1/graph/GraphRestrictor.java | 17 +++ 16 files changed, 394 insertions(+), 2 deletions(-) diff --git a/partiql-ast/api/partiql-ast.api b/partiql-ast/api/partiql-ast.api index b8df7c0cb..ac6ebdc2b 100644 --- a/partiql-ast/api/partiql-ast.api +++ b/partiql-ast/api/partiql-ast.api @@ -5855,6 +5855,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; @@ -5866,6 +5867,8 @@ public class org/partiql/ast/v1/DataType : org/partiql/ast/v1/Enum { public fun getPrecision ()Ljava/lang/Integer; public fun getScale ()Ljava/lang/Integer; public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/DataType; + public static fun values ()[Lorg/partiql/ast/v1/DataType; } public class org/partiql/ast/v1/DatetimeField : org/partiql/ast/v1/Enum { @@ -5891,6 +5894,8 @@ public class org/partiql/ast/v1/DatetimeField : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/DatetimeField; + public static fun values ()[Lorg/partiql/ast/v1/DatetimeField; } public abstract interface class org/partiql/ast/v1/Enum { @@ -6085,6 +6090,8 @@ public class org/partiql/ast/v1/FromType : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/FromType; + public static fun values ()[Lorg/partiql/ast/v1/FromType; } public class org/partiql/ast/v1/GroupBy : org/partiql/ast/v1/AstNode { @@ -6135,6 +6142,8 @@ public class org/partiql/ast/v1/GroupByStrategy : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/GroupByStrategy; + public static fun values ()[Lorg/partiql/ast/v1/GroupByStrategy; } public class org/partiql/ast/v1/Identifier : org/partiql/ast/v1/AstNode { @@ -6198,6 +6207,8 @@ public class org/partiql/ast/v1/JoinType : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/JoinType; + public static fun values ()[Lorg/partiql/ast/v1/JoinType; } public class org/partiql/ast/v1/Let : org/partiql/ast/v1/AstNode { @@ -6244,6 +6255,8 @@ public class org/partiql/ast/v1/Nulls : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/Nulls; + public static fun values ()[Lorg/partiql/ast/v1/Nulls; } public class org/partiql/ast/v1/Order : org/partiql/ast/v1/Enum { @@ -6257,6 +6270,8 @@ public class org/partiql/ast/v1/Order : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/Order; + public static fun values ()[Lorg/partiql/ast/v1/Order; } public class org/partiql/ast/v1/OrderBy : org/partiql/ast/v1/AstNode { @@ -6497,6 +6512,8 @@ public class org/partiql/ast/v1/SetOpType : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/SetOpType; + public static fun values ()[Lorg/partiql/ast/v1/SetOpType; } public class org/partiql/ast/v1/SetQuantifier : org/partiql/ast/v1/Enum { @@ -6510,6 +6527,8 @@ public class org/partiql/ast/v1/SetQuantifier : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/SetQuantifier; + public static fun values ()[Lorg/partiql/ast/v1/SetQuantifier; } public class org/partiql/ast/v1/Sort : org/partiql/ast/v1/AstNode { @@ -7279,6 +7298,8 @@ public class org/partiql/ast/v1/expr/Scope : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/expr/Scope; + public static fun values ()[Lorg/partiql/ast/v1/expr/Scope; } public class org/partiql/ast/v1/expr/SessionAttribute : org/partiql/ast/v1/Enum { @@ -7293,6 +7314,8 @@ public class org/partiql/ast/v1/expr/SessionAttribute : org/partiql/ast/v1/Enum public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/expr/SessionAttribute; + public static fun values ()[Lorg/partiql/ast/v1/expr/SessionAttribute; } public class org/partiql/ast/v1/expr/TrimSpec : org/partiql/ast/v1/Enum { @@ -7308,6 +7331,8 @@ public class org/partiql/ast/v1/expr/TrimSpec : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/expr/TrimSpec; + public static fun values ()[Lorg/partiql/ast/v1/expr/TrimSpec; } public class org/partiql/ast/v1/expr/WindowFunction : org/partiql/ast/v1/Enum { @@ -7322,6 +7347,8 @@ public class org/partiql/ast/v1/expr/WindowFunction : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/expr/WindowFunction; + public static fun values ()[Lorg/partiql/ast/v1/expr/WindowFunction; } public class org/partiql/ast/v1/graph/GraphDirection : org/partiql/ast/v1/Enum { @@ -7345,6 +7372,8 @@ public class org/partiql/ast/v1/graph/GraphDirection : org/partiql/ast/v1/Enum { public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/graph/GraphDirection; + public static fun values ()[Lorg/partiql/ast/v1/graph/GraphDirection; } public abstract class org/partiql/ast/v1/graph/GraphLabel : org/partiql/ast/v1/AstNode { @@ -7583,6 +7612,8 @@ public class org/partiql/ast/v1/graph/GraphRestrictor : org/partiql/ast/v1/Enum public fun code ()I public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I + public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/v1/graph/GraphRestrictor; + public static fun values ()[Lorg/partiql/ast/v1/graph/GraphRestrictor; } public abstract class org/partiql/ast/v1/graph/GraphSelector : org/partiql/ast/v1/AstNode { 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 2a734b2f9..70804ebe3 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 @@ -1,6 +1,7 @@ package org.partiql.ast.v1; import lombok.EqualsAndHashCode; +import org.jetbrains.annotations.NotNull; @EqualsAndHashCode(callSuper = false) public class DataType implements Enum { @@ -349,7 +350,11 @@ public static DataType INTERVAL() { return new DataType(INTERVAL); } - public static DataType USER_DEFINED(IdentifierChain name) { + public static DataType USER_DEFINED() { + return new DataType(USER_DEFINED); + } + + public static DataType USER_DEFINED(@NotNull IdentifierChain name) { return new DataType(USER_DEFINED, name); } @@ -391,6 +396,109 @@ public int code() { return code; } + public static DataType valueOf(String value) { + switch (value) { + case "NULL": return NULL(); + case "MISSING": return MISSING(); + case "BOOL": return BOOL(); + case "BOOLEAN": return BOOLEAN(); + case "TINYINT": return TINYINT(); + case "SMALLINT": return SMALLINT(); + case "INTEGER2": return INTEGER2(); + case "INT2": return INT2(); + case "INTEGER": return INTEGER(); + case "INT": return INT(); + case "INTEGER4": return INTEGER4(); + case "INT4": return INT4(); + case "INTEGER8": return INTEGER8(); + case "INT8": return INT8(); + case "BIGINT": return BIGINT(); + case "REAL": return REAL(); + case "DOUBLE_PRECISION": return DOUBLE_PRECISION(); + case "FLOAT": return FLOAT(); + case "DECIMAL": return DECIMAL(); + case "DEC": return DEC(); + case "NUMERIC": return NUMERIC(); + case "BIT": return BIT(); + case "BIT_VARYING": return BIT_VARYING(); + case "CHAR": return CHAR(); + case "CHARACTER": return CHARACTER(); + case "VARCHAR": return VARCHAR(); + case "CHARACTER_LARGE_OBJECT": return CHARACTER_LARGE_OBJECT(); + case "CHAR_LARGE_OBJECT": return CHAR_LARGE_OBJECT(); + case "CHAR_VARYING": return CHAR_VARYING(); + case "STRING": return STRING(); + case "SYMBOL": return SYMBOL(); + case "BLOB": return BLOB(); + case "BINARY_LARGE_OBJECT": return BINARY_LARGE_OBJECT(); + case "CLOB": return CLOB(); + case "DATE": return DATE(); + case "STRUCT": return STRUCT(); + case "TUPLE": return TUPLE(); + case "LIST": return LIST(); + case "SEXP": return SEXP(); + case "BAG": return BAG(); + case "TIME": return TIME(); + case "TIME_WITH_TIME_ZONE": return TIME_WITH_TIME_ZONE(); + case "TIMESTAMP": return TIMESTAMP(); + case "TIMESTAMP_WITH_TIME_ZONE": return TIMESTAMP_WITH_TIME_ZONE(); + case "INTERVAL": return INTERVAL(); + case "USER_DEFINED": return USER_DEFINED(); + default: return UNKNOWN(); + } + } + + public static DataType[] values() { + return new DataType[] { + NULL(), + MISSING(), + BOOL(), + BOOLEAN(), + TINYINT(), + SMALLINT(), + INTEGER2(), + INT2(), + INTEGER(), + INT(), + INTEGER4(), + INT4(), + INTEGER8(), + INT8(), + BIGINT(), + REAL(), + DOUBLE_PRECISION(), + FLOAT(), + DECIMAL(), + DEC(), + NUMERIC(), + BIT(), + BIT_VARYING(), + CHAR(), + CHARACTER(), + VARCHAR(), + CHARACTER_LARGE_OBJECT(), + CHAR_LARGE_OBJECT(), + CHAR_VARYING(), + STRING(), + SYMBOL(), + BLOB(), + BINARY_LARGE_OBJECT(), + CLOB(), + DATE(), + STRUCT(), + TUPLE(), + LIST(), + SEXP(), + BAG(), + TIME(), + TIME_WITH_TIME_ZONE(), + TIMESTAMP(), + TIMESTAMP_WITH_TIME_ZONE(), + INTERVAL(), + USER_DEFINED() + }; + } + /** * TODO docs * @return diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/DatetimeField.java b/partiql-ast/src/main/java/org/partiql/ast/v1/DatetimeField.java index e5a34541c..2c8d42a69 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/DatetimeField.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/DatetimeField.java @@ -63,4 +63,31 @@ private DatetimeField(int code) { public int code() { return code; } + + public static DatetimeField valueOf(String value) { + switch (value) { + case "YEAR": return YEAR(); + case "MONTH": return MONTH(); + case "DAY": return DAY(); + case "HOUR": return HOUR(); + case "MINUTE": return MINUTE(); + case "SECOND": return SECOND(); + case "TIMEZONE_HOUR": return TIMEZONE_HOUR(); + case "TIMEZONE_MINUTE": return TIMEZONE_MINUTE(); + default: return UNKNOWN(); + } + } + + public static DatetimeField[] values() { + return new DatetimeField[] { + YEAR(), + MONTH(), + DAY(), + HOUR(), + MINUTE(), + SECOND(), + TIMEZONE_HOUR(), + TIMEZONE_MINUTE() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/FromType.java b/partiql-ast/src/main/java/org/partiql/ast/v1/FromType.java index b563f70d8..74e0f7db9 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/FromType.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/FromType.java @@ -33,4 +33,19 @@ private FromType(int code) { public int code() { return code; } + + public static FromType valueOf(String value) { + switch (value) { + case "SCAN": return SCAN(); + case "UNPIVOT": return UNPIVOT(); + default: return UNKNOWN(); + } + } + + public static FromType[] values() { + return new FromType[] { + SCAN(), + UNPIVOT() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/GroupByStrategy.java b/partiql-ast/src/main/java/org/partiql/ast/v1/GroupByStrategy.java index 3329ea556..a24e1316f 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/GroupByStrategy.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/GroupByStrategy.java @@ -33,4 +33,19 @@ private GroupByStrategy(int code) { public int code() { return code; } + + public static GroupByStrategy valueOf(String value) { + switch (value) { + case "FULL": return FULL(); + case "PARTIAL": return PARTIAL(); + default: return UNKNOWN(); + } + } + + public static GroupByStrategy[] values() { + return new GroupByStrategy[] { + FULL(), + PARTIAL() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/JoinType.java b/partiql-ast/src/main/java/org/partiql/ast/v1/JoinType.java index af4a13ba3..8a3c33e69 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/JoinType.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/JoinType.java @@ -63,4 +63,31 @@ private JoinType(int code) { public int code() { return code; } + + public static JoinType valueOf(String value) { + switch (value) { + case "INNER": return INNER(); + case "LEFT": return LEFT(); + case "LEFT_OUTER": return LEFT_OUTER(); + case "RIGHT": return RIGHT(); + case "RIGHT_OUTER": return RIGHT_OUTER(); + case "FULL": return FULL(); + case "FULL_OUTER": return FULL_OUTER(); + case "CROSS": return CROSS(); + default: return UNKNOWN(); + } + } + + public static JoinType[] values() { + return new JoinType[] { + INNER(), + LEFT(), + LEFT_OUTER(), + RIGHT(), + RIGHT_OUTER(), + FULL(), + FULL_OUTER(), + CROSS() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/Nulls.java b/partiql-ast/src/main/java/org/partiql/ast/v1/Nulls.java index 4b90b1157..b1a5c7b41 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/Nulls.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/Nulls.java @@ -33,4 +33,20 @@ private Nulls(int code) { public int code() { return code; } + + public static Nulls valueOf(String value) { + switch (value) { + case "UNKNOWN": return UNKNOWN(); + case "FIRST": return FIRST(); + case "LAST": return LAST(); + default: return UNKNOWN(); + } + } + + public static Nulls[] values() { + return new Nulls[] { + FIRST(), + LAST() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/Order.java b/partiql-ast/src/main/java/org/partiql/ast/v1/Order.java index eb451ee4a..18f888d05 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/Order.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/Order.java @@ -30,4 +30,19 @@ private Order(int code) { public int code() { return code; } + + public static Order valueOf(String value) { + switch (value) { + case "ASC": return ASC(); + case "DESC": return DESC(); + default: return UNKNOWN(); + } + } + + public static Order[] values() { + return new Order[] { + ASC(), + DESC() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/SetOpType.java b/partiql-ast/src/main/java/org/partiql/ast/v1/SetOpType.java index 1d5bc233e..1a6b71f20 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/SetOpType.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/SetOpType.java @@ -38,4 +38,22 @@ private SetOpType(int code) { public int code() { return code; } + + public static SetOpType valueOf(String value) { + switch (value) { + case "UNKNOWN": return UNKNOWN(); + case "UNION": return UNION(); + case "INTERSECT": return INTERSECT(); + case "EXCEPT": return EXCEPT(); + default: return UNKNOWN(); + } + } + + public static SetOpType[] values() { + return new SetOpType[] { + UNION(), + INTERSECT(), + EXCEPT() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/SetQuantifier.java b/partiql-ast/src/main/java/org/partiql/ast/v1/SetQuantifier.java index 43f14f2fb..d5902d00c 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/SetQuantifier.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/SetQuantifier.java @@ -33,4 +33,19 @@ private SetQuantifier(int code) { public int code() { return code; } -} \ No newline at end of file + + public static SetQuantifier valueOf(String value) { + switch (value) { + case "ALL": return ALL(); + case "DISTINCT": return DISTINCT(); + default: return UNKNOWN(); + } + } + + public static SetQuantifier[] values() { + return new SetQuantifier[] { + ALL(), + DISTINCT() + }; + } +} diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/Scope.java b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/Scope.java index 0c65a933c..ea2e2abdc 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/Scope.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/Scope.java @@ -34,4 +34,20 @@ private Scope(int code) { public int code() { return code; } + + public static Scope valueOf(String value) { + switch (value) { + case "UNKNOWN": return UNKNOWN(); + case "DEFAULT": return DEFAULT(); + case "LOCAL": return LOCAL(); + default: return UNKNOWN(); + } + } + + public static Scope[] values() { + return new Scope[] { + DEFAULT(), + LOCAL() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/SessionAttribute.java b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/SessionAttribute.java index 86c00da63..56a348da3 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/SessionAttribute.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/SessionAttribute.java @@ -34,4 +34,19 @@ public SessionAttribute(int code) { public int code() { return code; } + + public static SessionAttribute valueOf(String value) { + switch (value) { + case "CURRENT_USER": return CURRENT_USER(); + case "CURRENT_DATE": return CURRENT_DATE(); + default: return UNKNOWN(); + } + } + + public static SessionAttribute[] values() { + return new SessionAttribute[] { + CURRENT_USER(), + CURRENT_DATE() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/TrimSpec.java b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/TrimSpec.java index 3f1295a44..00185925f 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/TrimSpec.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/TrimSpec.java @@ -36,4 +36,21 @@ private TrimSpec(int code) { public int code() { return code; } + + public static TrimSpec valueOf(String value) { + switch (value) { + case "LEADING": return LEADING(); + case "TRAILING": return TRAILING(); + case "BOTH": return BOTH(); + default: return UNKNOWN(); + } + } + + public static TrimSpec[] values() { + return new TrimSpec[] { + LEADING(), + TRAILING(), + BOTH() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/WindowFunction.java b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/WindowFunction.java index 4085ac92b..c312f30c6 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/expr/WindowFunction.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/expr/WindowFunction.java @@ -34,4 +34,19 @@ public WindowFunction(int code) { public int code() { return code; } + + public static WindowFunction valueOf(String value) { + switch (value) { + case "LAG": return LAG(); + case "LEAD": return LEAD(); + default: return UNKNOWN(); + } + } + + public static WindowFunction[] values() { + return new WindowFunction[] { + LAG(), + LEAD() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphDirection.java b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphDirection.java index c2d8f092c..db8ff4b68 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphDirection.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphDirection.java @@ -59,4 +59,29 @@ private GraphDirection(int code) { public int code() { return code; } + + public static GraphDirection valueOf(String value) { + switch (value) { + case "LEFT": return LEFT(); + case "UNDIRECTED": return UNDIRECTED(); + case "RIGHT": return RIGHT(); + case "LEFT_OR_UNDIRECTED": return LEFT_OR_UNDIRECTED(); + case "UNDIRECTED_OR_RIGHT": return UNDIRECTED_OR_RIGHT(); + case "LEFT_OR_RIGHT": return LEFT_OR_RIGHT(); + case "LEFT_UNDIRECTED_OR_RIGHT": return LEFT_UNDIRECTED_OR_RIGHT(); + default: return UNKNOWN(); + } + } + + public static GraphDirection[] values() { + return new GraphDirection[] { + LEFT(), + UNDIRECTED(), + RIGHT(), + LEFT_OR_UNDIRECTED(), + UNDIRECTED_OR_RIGHT(), + LEFT_OR_RIGHT(), + LEFT_UNDIRECTED_OR_RIGHT() + }; + } } diff --git a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphRestrictor.java b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphRestrictor.java index dcdde8f5c..c73e939b1 100644 --- a/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphRestrictor.java +++ b/partiql-ast/src/main/java/org/partiql/ast/v1/graph/GraphRestrictor.java @@ -39,4 +39,21 @@ private GraphRestrictor(int code) { public int code() { return code; } + + public static GraphRestrictor valueOf(String value) { + switch (value) { + case "TRAIL": return TRAIL(); + case "ACYCLIC": return ACYCLIC(); + case "SIMPLE": return SIMPLE(); + default: return UNKNOWN(); + } + } + + public static GraphRestrictor[] values() { + return new GraphRestrictor[] { + TRAIL(), + ACYCLIC(), + SIMPLE() + }; + } }