Merging upstream version 10.1.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
582b160275
commit
a5128ea109
57 changed files with 1542 additions and 529 deletions
|
@ -289,19 +289,19 @@ def struct_extract_sql(self, expression):
|
|||
return f"{this}.{struct_key}"
|
||||
|
||||
|
||||
def var_map_sql(self, expression):
|
||||
def var_map_sql(self, expression, map_func_name="MAP"):
|
||||
keys = expression.args["keys"]
|
||||
values = expression.args["values"]
|
||||
|
||||
if not isinstance(keys, exp.Array) or not isinstance(values, exp.Array):
|
||||
self.unsupported("Cannot convert array columns into map.")
|
||||
return f"MAP({self.format_args(keys, values)})"
|
||||
return f"{map_func_name}({self.format_args(keys, values)})"
|
||||
|
||||
args = []
|
||||
for key, value in zip(keys.expressions, values.expressions):
|
||||
args.append(self.sql(key))
|
||||
args.append(self.sql(value))
|
||||
return f"MAP({self.format_args(*args)})"
|
||||
return f"{map_func_name}({self.format_args(*args)})"
|
||||
|
||||
|
||||
def format_time_lambda(exp_class, dialect, default=None):
|
||||
|
@ -336,18 +336,13 @@ def create_with_partitions_sql(self, expression):
|
|||
if has_schema and is_partitionable:
|
||||
expression = expression.copy()
|
||||
prop = expression.find(exp.PartitionedByProperty)
|
||||
value = prop and prop.args.get("value")
|
||||
if prop and not isinstance(value, exp.Schema):
|
||||
this = prop and prop.this
|
||||
if prop and not isinstance(this, exp.Schema):
|
||||
schema = expression.this
|
||||
columns = {v.name.upper() for v in value.expressions}
|
||||
columns = {v.name.upper() for v in this.expressions}
|
||||
partitions = [col for col in schema.expressions if col.name.upper() in columns]
|
||||
schema.set(
|
||||
"expressions",
|
||||
[e for e in schema.expressions if e not in partitions],
|
||||
)
|
||||
prop.replace(
|
||||
exp.PartitionedByProperty(this=prop.this, value=exp.Schema(expressions=partitions))
|
||||
)
|
||||
schema.set("expressions", [e for e in schema.expressions if e not in partitions])
|
||||
prop.replace(exp.PartitionedByProperty(this=exp.Schema(expressions=partitions)))
|
||||
expression.set("this", schema)
|
||||
|
||||
return self.create_sql(expression)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue