1
0
Fork 0

Adding upstream version 25.7.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:51:31 +01:00
parent f9dae8e951
commit 8356f462bb
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
102 changed files with 52995 additions and 52070 deletions

View file

@ -229,6 +229,23 @@ def unqualify_unnest(expression: exp.Expression) -> exp.Expression:
def unnest_to_explode(expression: exp.Expression) -> exp.Expression:
"""Convert cross join unnest into lateral view explode."""
if isinstance(expression, exp.Select):
from_ = expression.args.get("from")
if from_ and isinstance(from_.this, exp.Unnest):
unnest = from_.this
alias = unnest.args.get("alias")
udtf = exp.Posexplode if unnest.args.get("offset") else exp.Explode
this, *expressions = unnest.expressions
unnest.replace(
exp.Table(
this=udtf(
this=this,
expressions=expressions,
),
alias=exp.TableAlias(this=alias.this, columns=alias.columns) if alias else None,
)
)
for join in expression.args.get("joins") or []:
unnest = join.this