From 2fbca6fa9571be27a3a60e75930255818b2d331c Mon Sep 17 00:00:00 2001 From: Gaurav Sagar Date: Wed, 30 Oct 2024 14:31:36 +0530 Subject: [PATCH] fix formatting --- sqlglot/transforms.py | 12 ++++-------- tests/dialects/test_starrocks.py | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sqlglot/transforms.py b/sqlglot/transforms.py index 5f517612ea..e52c2460d3 100644 --- a/sqlglot/transforms.py +++ b/sqlglot/transforms.py @@ -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) @@ -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. @@ -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", @@ -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, ), ), ) diff --git a/tests/dialects/test_starrocks.py b/tests/dialects/test_starrocks.py index 28bda4ade8..1ec319a643 100644 --- a/tests/dialects/test_starrocks.py +++ b/tests/dialects/test_starrocks.py @@ -1,4 +1,3 @@ -from sqlglot.errors import UnsupportedError from tests.dialects.test_dialect import Validator