Skip to content

Commit dc461da

Browse files
committed
Fixup
1 parent 7d38b63 commit dc461da

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

sqlglot/dialects/hive.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ 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
2827

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

sqlglot/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ class Parser:
421421
"UNNEST": lambda args: exp.Unnest(expressions=ensure_list(seq_get(args, 0))),
422422
"UPPER": build_upper,
423423
"UUID": lambda args, dialect: exp.Uuid(is_string=dialect.UUID_IS_STRING_TYPE or None),
424+
"UUID_STRING": lambda args, dialect: exp.Uuid(
425+
this=seq_get(args, 0),
426+
name=seq_get(args, 1),
427+
is_string=dialect.UUID_IS_STRING_TYPE or None,
428+
),
424429
"VAR_MAP": build_var_map,
425430
}
426431

sqlglot/parsers/snowflake.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ 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)),
719718
"WEEKISO": exp.WeekOfYear.from_arg_list,
720719
"WEEKOFYEAR": exp.Week.from_arg_list,
721720
}

tests/dialects/test_dialect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3881,7 +3881,6 @@ def test_uuid(self):
38813881
"trino": "UUID()",
38823882
"mysql": "UUID()",
38833883
"postgres": "GEN_RANDOM_UUID()",
3884-
"snowflake": "UUID_STRING()",
38853884
"tsql": "NEWID()",
38863885
},
38873886
write={

tests/dialects/test_snowflake.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,13 +2217,13 @@ def test_snowflake(self):
22172217
"snowflake": "UUID_STRING('fe971b24-9572-4005-b22f-351e9c09274d', 'foo')",
22182218
},
22192219
write={
2220-
"hive": "UUID()",
2221-
"spark2": "UUID()",
2222-
"spark": "UUID()",
2223-
"databricks": "UUID()",
2220+
"hive": "CAST(UUID() AS STRING)",
2221+
"spark2": "CAST(UUID() AS STRING)",
2222+
"spark": "CAST(UUID() AS STRING)",
2223+
"databricks": "CAST(UUID() AS STRING)",
22242224
"duckdb": "(SELECT LOWER(SUBSTRING(h, 1, 8) || '-' || SUBSTRING(h, 9, 4) || '-' || '5' || SUBSTRING(h, 14, 3) || '-' || FORMAT('{:02x}', CAST('0x' || SUBSTRING(h, 17, 2) AS INT) & 63 | 128) || SUBSTRING(h, 19, 2) || '-' || SUBSTRING(h, 21, 12)) FROM (SELECT SUBSTRING(SHA1(UNHEX(REPLACE('fe971b24-9572-4005-b22f-351e9c09274d', '-', '')) || ENCODE('foo')), 1, 32) AS h))",
2225-
"presto": "UUID()",
2226-
"trino": "UUID()",
2225+
"presto": "CAST(UUID() AS VARCHAR)",
2226+
"trino": "CAST(UUID() AS VARCHAR)",
22272227
"postgres": "GEN_RANDOM_UUID()",
22282228
"bigquery": "GENERATE_UUID()",
22292229
},

0 commit comments

Comments
 (0)