1
0
Fork 0

Adding upstream version 18.5.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:02:03 +01:00
parent 649252bd84
commit c4fc25c23b
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
67 changed files with 32690 additions and 32450 deletions

View file

@ -7,6 +7,7 @@ from sqlglot.dialects.dialect import (
binary_from_function,
create_with_partitions_sql,
format_time_lambda,
is_parse_json,
pivot_column_names,
rename_func,
trim_sql,
@ -242,10 +243,11 @@ class Spark2(Hive):
CREATE_FUNCTION_RETURN_AS = False
def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) -> str:
if isinstance(expression.this, exp.Cast) and expression.this.is_type("json"):
if is_parse_json(expression.this):
schema = f"'{self.sql(expression, 'to')}'"
return self.func("FROM_JSON", expression.this.this, schema)
if expression.is_type("json"):
if is_parse_json(expression):
return self.func("TO_JSON", expression.this)
return super(Hive.Generator, self).cast_sql(expression, safe_prefix=safe_prefix)