Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav Sagar committed Oct 30, 2024
1 parent 9d443cd commit 2fbca6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 4 additions & 8 deletions sqlglot/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,13 @@ def unqualify_unnest(expression: exp.Expression) -> exp.Expression:
return expression


def unnest_to_explode(
expression: exp.Expression
) -> exp.Expression:
def unnest_to_explode(expression: exp.Expression) -> exp.Expression:
"""Convert cross join unnest into lateral view explode."""

def _unnest_zip_exprs(
u: exp.Unnest, unnest_exprs: t.List[exp.Expression], has_multi_expr: bool
) -> t.List[exp.Expression]:
if has_multi_expr:

# Use INLINE(ARRAYS_ZIP(...)) for multiple expressions
zip_exprs: t.List[exp.Expression] = [
exp.Anonymous(this="ARRAYS_ZIP", expressions=unnest_exprs)
Expand Down Expand Up @@ -365,8 +362,7 @@ def _udtf_type(u: exp.Unnest, has_multi_expr: bool) -> t.Type[exp.Func]:
expression.args["joins"].remove(join)

alias_cols = alias.columns if alias else []



"""
Handle Presto CROSS JOIN UNNEST to LATERAL VIEW EXPLODE for Multiple or No Exploded table column alias.
Expand All @@ -383,7 +379,7 @@ def _udtf_type(u: exp.Unnest, has_multi_expr: bool) -> t.Type[exp.Func]:
for column in expression.find_all(exp.Column):
if alias and column.table == alias.name:
column.set("table", "t_struct")

for e, column in zip(exprs, alias_cols):
expression.append(
"laterals",
Expand All @@ -392,7 +388,7 @@ def _udtf_type(u: exp.Unnest, has_multi_expr: bool) -> t.Type[exp.Func]:
view=True,
alias=exp.TableAlias(
this=alias.this, # type: ignore
columns=alias_cols
columns=alias_cols,
),
),
)
Expand Down
1 change: 0 additions & 1 deletion tests/dialects/test_starrocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sqlglot.errors import UnsupportedError
from tests.dialects.test_dialect import Validator


Expand Down

0 comments on commit 2fbca6f

Please sign in to comment.