Skip to content

Fix BigQuery string literal apostrophe escaping issue in filters (#35857)#40455

Open
Jualhosting wants to merge 3 commits into
apache:masterfrom
Jualhosting:fix-bigquery-apostrophe
Open

Fix BigQuery string literal apostrophe escaping issue in filters (#35857)#40455
Jualhosting wants to merge 3 commits into
apache:masterfrom
Jualhosting:fix-bigquery-apostrophe

Conversation

@Jualhosting
Copy link
Copy Markdown

@Jualhosting Jualhosting commented May 27, 2026

Fixes #35857 by overriding BindParameter compilation for bigquery dialect to use backslash escaping for single quotes.

SUMMARY

Fixes BigQuery string literal apostrophe escaping issue in filters by overriding the BindParameter compilation for the BigQuery dialect to use backslash escaping.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Unit tests verify the correct escaping behavior for the BigQuery dialect.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

AI Assistance Disclosure

This PR was developed with the assistance of Antigravity (a Gemini-based AI coding assistant). The contributor has reviewed and validated all changes.

@dosubot dosubot Bot added the data:connect:googlebigquery Related to BigQuery label May 27, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 27, 2026

Code Review Agent Run #c823cb

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/db_engine_specs/bigquery.py - 2
    • Missing test coverage · Line 46-56
      This custom bind parameter compiler has no unit tests despite modifying SQL generation for all BigQuery queries. Per BITO.md rule [6262], tests should verify actual business logic — the docstring claims this fixes '400 POST syntax errors on filters with apostrophes', so test cases must include multi-apostrophe strings and edge cases like pre-escaped backslashes.
    • Missing precondition docs · Line 53-53
      The escape logic only applies when `literal_binds=True` is set in compile_kwargs. This creates an implicit contract that callers must set this flag. Consider documenting the expected usage pattern or adding an assertion.
Review Details
  • Files reviewed - 1 · Commit Range: f2ed8a9..f2ed8a9
    • superset/db_engine_specs/bigquery.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/db_engine_specs/bigquery.py
@bito-code-review
Copy link
Copy Markdown
Contributor

The PR comments file contains only one comment entry, which matches the suggestion in question. The suggestion is valid and addresses a logic error in the BigQuery literal compiler. The current implementation escapes single quotes but leaves backslashes untouched, which can lead to invalid SQL when values end with a backslash. The suggested fix is to escape backslashes before apostrophes or use the dialect literal processor to ensure valid string literals for all inputs.

superset/db_engine_specs/bigquery.py

val = element.value.replace("'", "\\'"); return f"'{val}'"

superset/db_engine_specs/bigquery.py

val = element.value.replace("\\", "\\\\").replace("'", "\\'"); return f"'{val}'"

@Jualhosting
Copy link
Copy Markdown
Author

/resolve

@pull-request-size pull-request-size Bot added size/M and removed size/S labels May 28, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 28, 2026

Code Review Agent Run #5b7de6

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f2ed8a9..b094df2
    • tests/unit_tests/db_engine_specs/test_bigquery.py
    • superset/db_engine_specs/bigquery.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigQuery errors when filters on text columns have apostrophes in them

1 participant