fix(unparser): make BigQueryDialect more robust#21296
Open
sgrebnov wants to merge 1 commit intoapache:mainfrom
Open
fix(unparser): make BigQueryDialect more robust#21296sgrebnov wants to merge 1 commit intoapache:mainfrom
BigQueryDialect more robust#21296sgrebnov wants to merge 1 commit intoapache:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
PR improves
BigQueryDialectdialect to make generated SQLBigQuery-compatible (fix execution errors).What changes are included in this PR?
Eight
Dialecttrait overrides added toBigQueryDialect:https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/data-types
date_field_extract_style→Extract+scalar_function_to_sql_overridesBigQuery does not support
date_part(). TPC-H Q7, Q8, Q9 fail withFunction not found: date_part.date_part('YEAR', l_shipdate)EXTRACT(YEAR FROM l_shipdate)interval_style→SQLStandardBigQuery does not support PostgreSQL-style interval abbreviations. TPC-H Q4, Q20 fail with
Syntax error: Unexpected ")".INTERVAL '3 MONS'INTERVAL '3' MONTHfloat64_ast_dtype→Float64BigQuery does not support
DOUBLE. Fails withType not found: DOUBLE.CAST(a AS DOUBLE)CAST(a AS FLOAT64)supports_column_alias_in_table_alias→falseBigQuery does not support column aliases in table alias definitions. Fails with
Expected ")" but got "(".SELECT c.key FROM (...) AS c(key)SELECT c.key FROM (SELECT o_orderkey AS key FROM orders) AS cutf8_cast_dtype+large_utf8_cast_dtype→StringBigQuery does not support
VARCHAR/TEXT. Fails withType not found: VARCHAR,Type not found: Text.CAST(a AS VARCHAR)CAST(a AS STRING)CAST(a AS TEXT)CAST(a AS STRING)int64_cast_dtype→Int64BigQuery does not support
BIGINT. Fails withType not found: BIGINT.CAST(a AS BIGINT)CAST(a AS INT64)timestamp_cast_dtype→Timestamp(no timezone qualifier)https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type
BigQuery does not support
TIMESTAMP WITH TIME ZONE. Fails withSyntax error: Expected ')' or keyword FORMAT but got keyword WITH.TIMESTAMPshould be used (preserves time zone information)/CAST(a AS TIMESTAMP WITH TIME ZONE)CAST(a AS TIMESTAMP)Are these changes tested?
Yes. Added
test_bigquery_dialect_overridesunit test covering all eight overrides, verified against BigQuery before and after.Are there any user-facing changes?
No API changes.
BigQueryDialectnow generates valid BigQuery SQL for the affected expressions.