Skip to content

Commit 83595b6

Browse files
committedJan 7, 2025··
Feat(hive)!: parse ASCII into Unicode to facilitate transpilation
1 parent 231d032 commit 83595b6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎sqlglot/dialects/hive.py

+2
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ class Parser(parser.Parser):
277277

278278
FUNCTIONS = {
279279
**parser.Parser.FUNCTIONS,
280+
"ASCII": exp.Unicode.from_arg_list,
280281
"BASE64": exp.ToBase64.from_arg_list,
281282
"COLLECT_LIST": lambda args: exp.ArrayAgg(this=seq_get(args, 0), nulls_excluded=True),
282283
"COLLECT_SET": exp.ArrayUniqueAgg.from_arg_list,
@@ -582,6 +583,7 @@ class Generator(generator.Generator):
582583
exp.TsOrDsDiff: _date_diff_sql,
583584
exp.TsOrDsToDate: _to_date_sql,
584585
exp.TryCast: no_trycast_sql,
586+
exp.Unicode: rename_func("ASCII"),
585587
exp.UnixToStr: lambda self, e: self.func(
586588
"FROM_UNIXTIME", e.this, time_format("hive")(self, e)
587589
),

‎tests/dialects/test_sqlite.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ def test_sqlite(self):
9595
self.validate_all(
9696
"UNICODE(x)",
9797
write={
98+
"": "UNICODE(x)",
9899
"mysql": "ORD(CONVERT(x USING utf32))",
99-
"postgres": "ASCII(x)",
100100
"oracle": "ASCII(UNISTR(x))",
101+
"postgres": "ASCII(x)",
102+
"redshift": "ASCII(x)",
103+
"spark": "ASCII(x)",
101104
},
102105
)
103106
self.validate_identity(

0 commit comments

Comments
 (0)
Please sign in to comment.