1
0
Fork 0

Adding upstream version 22.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:29:15 +01:00
parent b01402dc30
commit f1aa09959c
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
148 changed files with 68457 additions and 63176 deletions

View file

@ -453,11 +453,32 @@ class Presto(Dialect):
return super().bracket_sql(expression)
def struct_sql(self, expression: exp.Struct) -> str:
if any(isinstance(arg, self.KEY_VALUE_DEFINITIONS) for arg in expression.expressions):
self.unsupported("Struct with key-value definitions is unsupported.")
return self.function_fallback_sql(expression)
from sqlglot.optimizer.annotate_types import annotate_types
return rename_func("ROW")(self, expression)
expression = annotate_types(expression)
values: t.List[str] = []
schema: t.List[str] = []
unknown_type = False
for e in expression.expressions:
if isinstance(e, exp.PropertyEQ):
if e.type and e.type.is_type(exp.DataType.Type.UNKNOWN):
unknown_type = True
else:
schema.append(f"{self.sql(e, 'this')} {self.sql(e.type)}")
values.append(self.sql(e, "expression"))
else:
values.append(self.sql(e))
size = len(expression.expressions)
if not size or len(schema) != size:
if unknown_type:
self.unsupported(
"Cannot convert untyped key-value definitions (try annotate_types)."
)
return self.func("ROW", *values)
return f"CAST(ROW({', '.join(values)}) AS ROW({', '.join(schema)}))"
def interval_sql(self, expression: exp.Interval) -> str:
unit = self.sql(expression, "unit")