Skip to content

Commit b828e30

Browse files
fivetran-ashashankargeorgesittas
authored andcommitted
feat(snowflake): add UUID_IS_STRING_TYPE flag and UUID_STRING parser
- Set UUID_IS_STRING_TYPE = True in Snowflake dialect - Add UUID_STRING parser that sets is_string=True flag - Explicitly set UUID_IS_STRING_TYPE = False in Hive, Presto, and DuckDB dialects
1 parent 49787a5 commit b828e30

5 files changed

Lines changed: 5 additions & 0 deletions

File tree

sqlglot/dialects/duckdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class DuckDB(Dialect):
2424
SUPPORTS_FIXED_SIZE_ARRAYS = True
2525
STRICT_JSON_PATH_SYNTAX = False
2626
NUMBERS_CAN_BE_UNDERSCORE_SEPARATED = True
27+
UUID_IS_STRING_TYPE = False
2728

2829
# https://duckdb.org/docs/sql/introduction.html#creating-a-new-table
2930
NORMALIZATION_STRATEGY = NormalizationStrategy.CASE_INSENSITIVE

sqlglot/dialects/hive.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Hive(Dialect):
2424
ARRAY_AGG_INCLUDES_NULLS = None
2525
REGEXP_EXTRACT_DEFAULT_GROUP = 1
2626
ALTER_TABLE_SUPPORTS_CASCADE = True
27+
UUID_IS_STRING_TYPE = False
2728

2829
# https://spark.apache.org/docs/latest/sql-ref-identifier.html#description
2930
NORMALIZATION_STRATEGY = NormalizationStrategy.CASE_INSENSITIVE

sqlglot/dialects/presto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Presto(Dialect):
2424
LOG_BASE_FIRST: bool | None = None
2525
SUPPORTS_VALUES_DEFAULT = False
2626
LEAST_GREATEST_IGNORES_NULLS = False
27+
UUID_IS_STRING_TYPE = False
2728

2829
TIME_MAPPING = MySQL.TIME_MAPPING
2930

sqlglot/dialects/snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Snowflake(Dialect):
2828
TRY_CAST_REQUIRES_STRING = True
2929
SUPPORTS_ALIAS_REFS_IN_JOIN_CONDITIONS = True
3030
LEAST_GREATEST_IGNORES_NULLS = False
31+
UUID_IS_STRING_TYPE = True
3132

3233
EXPRESSION_METADATA = EXPRESSION_METADATA.copy()
3334

sqlglot/parsers/snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ class SnowflakeParser(parser.Parser):
715715
),
716716
"SYSTIMESTAMP": exp.CurrentTimestamp.from_arg_list,
717717
"UNICODE": lambda args: exp.Unicode(this=seq_get(args, 0), empty_is_zero=True),
718+
"UUID_STRING": lambda args: exp.Uuid(this=seq_get(args, 0), name=seq_get(args, 1)),
718719
"WEEKISO": exp.WeekOfYear.from_arg_list,
719720
"WEEKOFYEAR": exp.Week.from_arg_list,
720721
}

0 commit comments

Comments
 (0)