dosubot[bot] commented on issue #35857:
URL: https://github.com/apache/superset/issues/35857#issuecomment-3451824231

   <!-- Answer -->
   Superset escapes apostrophes in filter values by doubling them (e.g., 
`O'Donnell` becomes `O''Donnell`), which is the standard SQL approach and 
should be accepted by BigQuery. However, the error message you’re 
seeing—`concatenated string literals must be separated by whitespace or 
comments`—suggests a syntax issue in how the query is constructed or formatted, 
not specifically with the escaping itself. This can happen if the generated SQL 
ends up with malformed string literals due to how values are concatenated or 
quoted in the filter clause, especially when special characters are involved 
[cite](https://github.com/apache/superset/blob/master/superset/db_engine_specs/bigquery.py).
   
   Recent pull requests have addressed string escaping issues for other 
databases (like Databricks and Athena), and there have been changes to SQL 
formatting and BigQuery dialect handling in newer Superset versions, but 
there’s no direct evidence of a fix for this specific BigQuery apostrophe 
filter bug in 4.1.3 [cite](https://github.com/apache/superset/pull/34991) 
[cite](https://github.com/apache/superset/pull/30350) 
[cite](https://github.com/apache/superset/pull/34371).
   
   As a workaround, you can try using Jinja templating in your dataset SQL to 
defensively handle filter values, for example:
   
   ```sql
   {% set values = filter_values('restaurant_name') %}
   {% if values %}
     AND restaurant_name IN ({{ values | where_in }})
   {% endif %}
   ```
   
   This ensures that the filter clause is only included if there are values, 
and uses Superset’s built-in escaping logic. If you’re using virtual datasets, 
make sure `ENABLE_TEMPLATE_PROCESSING` is enabled.
   
   If you need partial matching (e.g., `LIKE` instead of `IN`), note that 
Superset 4.x removed the Filter Box component that allowed for this, and the 
default filters only support exact matches. There’s ongoing discussion about 
making filter operators configurable, but for now, only exact matches are 
supported in the UI [cite](https://github.com/apache/superset/issues/32276).
   
   If this issue is blocking and you need a quick fix, upgrading to the latest 
Superset version may help if recent changes addressed related query formatting 
bugs. Otherwise, using Jinja templating as above or manually editing the 
generated SQL in SQL Lab are your best options for now.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/db7db8ab-7d03-4015-a525-d5672a1f0be8?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
 b)&nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/35857)


-- 
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