vijaygovindaraja opened a new pull request, #38925:
URL: https://github.com/apache/superset/pull/38925

   ## SUMMARY
   
   Fixes BigQuery syntax errors when filter values contain apostrophes (e.g., 
"Armando's").
   
   BigQuery does not support double-apostrophe escaping (`'Armando''s'`), which 
is the default behavior of SQLAlchemy's literal processor. This causes a `400 
Syntax error: concatenated string literals must be separated by whitespace or 
comments` error.
   
   ### BEFORE
   ```sql
   -- Generated SQL (broken)
   WHERE `restaurant_name` IN ('Armando''s')
   -- BigQuery error: Syntax error: concatenated string literals must be 
separated by whitespace
   ```
   
   ### AFTER
   ```sql
   -- Generated SQL (correct)
   WHERE `restaurant_name` IN ('Armando\'s')
   -- BigQuery executes successfully
   ```
   
   ## CHANGES
   
   **`superset/db_engine_specs/bigquery.py`:**
   - Add `BigQueryStringType` — a `TypeDecorator` that overrides 
`literal_processor` to use backslash escaping instead of double-apostrophe 
escaping
   - Add `_monkeypatch_bigquery_dialect()` — patches `BigQueryDialect.colspecs` 
to use the custom string type
   - Follows the same proven pattern as the Databricks dialect fix 
(`DatabricksStringType` + `monkeypatch_dialect()`)
   
   **`tests/unit_tests/jinja_context_test.py`:**
   - Add `test_where_in_bigquery_apostrophe` — verifies BigQuery dialect uses 
backslash escaping for filter values containing apostrophes
   
   ## TESTING INSTRUCTIONS
   
   1. Connect a BigQuery data source
   2. Create a filter on a text column
   3. Select a value containing an apostrophe (e.g., "Armando's", "O'Brien")
   4. Verify the chart/dashboard loads without a 400 syntax error
   
   ## ADDITIONAL INFORMATION
   - Fixes #35857
   - Pattern precedent: Databricks fix in 
`superset/db_engine_specs/databricks.py` lines 57-107


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to