Adding upstream version 25.30.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c61927f460
commit
44a4f87ffd
69 changed files with 48139 additions and 46098 deletions
|
@ -348,7 +348,8 @@ def unnest_to_explode(
|
|||
)
|
||||
)
|
||||
|
||||
for join in expression.args.get("joins") or []:
|
||||
joins = expression.args.get("joins") or []
|
||||
for join in list(joins):
|
||||
join_expr = join.this
|
||||
|
||||
is_lateral = isinstance(join_expr, exp.Lateral)
|
||||
|
@ -365,9 +366,19 @@ def unnest_to_explode(
|
|||
has_multi_expr = len(exprs) > 1
|
||||
exprs = _unnest_zip_exprs(unnest, exprs, has_multi_expr)
|
||||
|
||||
expression.args["joins"].remove(join)
|
||||
joins.remove(join)
|
||||
|
||||
alias_cols = alias.columns if alias else []
|
||||
|
||||
# # Handle UNNEST to LATERAL VIEW EXPLODE: Exception is raised when there are 0 or > 2 aliases
|
||||
# Spark LATERAL VIEW EXPLODE requires single alias for array/struct and two for Map type column unlike unnest in trino/presto which can take an arbitrary amount.
|
||||
# Refs: https://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-lateral-view.html
|
||||
|
||||
if not has_multi_expr and len(alias_cols) not in (1, 2):
|
||||
raise UnsupportedError(
|
||||
"CROSS JOIN UNNEST to LATERAL VIEW EXPLODE transformation requires explicit column aliases"
|
||||
)
|
||||
|
||||
for e, column in zip(exprs, alias_cols):
|
||||
expression.append(
|
||||
"laterals",
|
||||
|
@ -376,7 +387,7 @@ def unnest_to_explode(
|
|||
view=True,
|
||||
alias=exp.TableAlias(
|
||||
this=alias.this, # type: ignore
|
||||
columns=alias_cols if unnest_using_arrays_zip else [column], # type: ignore
|
||||
columns=alias_cols,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue