Skip to content

Commit

Permalink
Fix: bigquery don't strip nested types
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Jul 3, 2023
1 parent 6f80cc8 commit 82f8fff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sqlglot/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def remove_precision_parameterized_types(expression: exp.Expression) -> exp.Expr
other expressions. This transforms removes the precision from parameterized types in expressions.
"""
for node in expression.find_all(exp.DataType):
node.set("expressions", [e for e in node.expressions if isinstance(e, exp.DataType)])
node.set(
"expressions", [e for e in node.expressions if not isinstance(e, exp.DataTypeSize)]
)

return expression

Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_bigquery(self):
self.validate_identity("SELECT CAST(CURRENT_DATE AS STRING FORMAT 'DAY') AS current_day")
self.validate_identity("SAFE_CAST(encrypted_value AS STRING FORMAT 'BASE64')")
self.validate_identity("CAST(encrypted_value AS STRING FORMAT 'BASE64')")
self.validate_identity("CAST(STRUCT<a INT64>(1) AS STRUCT<a INT64>)")
self.validate_identity("STRING_AGG(a)")
self.validate_identity("STRING_AGG(a, ' & ')")
self.validate_identity("STRING_AGG(DISTINCT a, ' & ')")
Expand Down

0 comments on commit 82f8fff

Please sign in to comment.