Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@geooo109
Copy link
Collaborator

@geooo109 geooo109 commented Dec 18, 2025

This PR adds more robust type annotation for literals vs non-literals.

Prior this PR, the annotation of BigQuery wasn't literal sensitive.

For example:

Previously:
CASE WHEN TRUE THEN 2.5 ELSE CAST(3.5 AS BIGNUMERIC) END; -> annotated as FLOAT64

Currently:
CASE WHEN TRUE THEN 2.5 ELSE CAST(3.5 AS BIGNUMERIC) END; -> annotated as BIGNUMERIC

This ^ is wrong because the non-literal types have priority over literal ones.

DOCS
Literal/Non-literal type conversion

@geooo109 geooo109 marked this pull request as draft December 18, 2025 10:45
@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:geooo109/bq_annotate_literals, sqlglot version: geooo109/bq_annotate_literals)
  • baseline (main, sqlglot version: 28.5.1.dev22)

⚠️ Limited to dialects: bigquery, duckdb, snowflake

By Dialect

dialect main sqlglot:geooo109/bq_annotate_literals difference links
bigquery -> bigquery 2576/2621 passed (98.3%) 2576/2621 passed (98.3%) No change full result / delta
bigquery -> duckdb 1844/2620 passed (70.4%) 1846/2620 passed (70.5%) ⬆ improved by 0.1% full result / delta
duckdb -> duckdb 4003/4003 passed (100.0%) 4003/4003 passed (100.0%) No change full result / delta
snowflake -> duckdb 624/1085 passed (57.5%) 624/1085 passed (57.5%) No change full result / delta
snowflake -> snowflake 981/1085 passed (90.4%) 981/1085 passed (90.4%) No change full result / delta

Overall

main: 11414 total, 10028 passed (pass rate: 87.9%), sqlglot version: 28.5.1.dev22

sqlglot:geooo109/bq_annotate_literals: 11414 total, 10030 passed (pass rate: 87.9%), sqlglot version: geooo109/bq_annotate_literals

Difference: No change

@geooo109 geooo109 force-pushed the geooo109/bq_annotate_literals branch from 22db45d to 54cb8c1 Compare December 19, 2025 14:32
@geooo109
Copy link
Collaborator Author

Pushed the feedback, I will do a refactor, and it is ready.

@geooo109 geooo109 marked this pull request as ready for review December 19, 2025 16:38
@geooo109 geooo109 merged commit 1f3436b into main Dec 22, 2025
9 checks passed
@geooo109 geooo109 deleted the geooo109/bq_annotate_literals branch December 22, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants