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

   <!-- Answer -->
   This appears to be a driver-level issue rather than a Superset bug. Looking 
at the code, [Superset does NOT manually add backslash escape characters to 
filter 
values](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py#L1139-L1198)
 — it only strips tabs and newlines, then delegates SQL escaping to SQLAlchemy 
and the database driver.
   
   The backslash doubling you're seeing is likely coming from:
   1. **duckdb-engine driver** — The SQLAlchemy dialect for DuckDB may be 
escaping backslashes during parameter binding
   2. **DuckDB itself** — DuckDB might expect escaped backslashes in string 
literals
   
   **Suggested troubleshooting:**
   - Test if a raw SQL query with backslashes works correctly directly in 
DuckDB (outside Superset) to isolate where the escaping happens
   - Check if upgrading `duckdb-engine` resolves this, as [version-specific 
issues have been 
reported](https://github.com/apache/superset/issues/31978#issuecomment-2633389243)
   
   For reference, [similar escape character issues have occurred with other 
databases](https://github.com/apache/superset/issues/34342#issuecomment-3124815510)
 (Databricks, BigQuery) and required database-specific solutions like custom 
string escapers. If confirmed to be a duckdb-engine issue, a similar fix could 
potentially be implemented in [Superset's DuckDB engine 
spec](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/db_engine_specs/duckdb.py).
   
   
   <!-- 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/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/d0dcdccc-d98e-4b21-a009-0741381af05a?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20appears%20to%20be%20a%20driver-level%20issue%20rather%20than%20a%20Superset%20bug.%20Looking%20at%20the%20code%2C%20%5BSuperset%20does%20NOT%20manually%20add%20backslash%20escape%20characters%20to%20filter%20values%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py%23L1139-L1198%29%20%E2%80%94%20it%20only%20strips%20tabs%20and%20newlines%2C%20then%20delegates%20SQL%20escaping%20to%20SQLAlchemy%20and%20the%20database%20driver.%0A%0AThe%20backslash%20doubling%20you%27re%20seeing%20is%20likely%20coming%20from%3A%0A1.%20%2A%2Aduckdb-engine%20driver%2A%2A%20%E2%80%94%20The%20SQLAlchemy%20dialect%20for%20DuckDB%20may%20be%20escaping%20backslashes%20during%20parameter%20binding%0A2.%20
 
%2A%2ADuckDB%20itself%2A%2A%20%E2%80%94%20DuckDB%20might%20expect%20escaped%20backslashes%20in%20string%20literals%0A%0A%2A%2ASuggested%20troubleshooting%3A%2A%2A%0A-%20Test%20if%20a%20raw%20SQL%20query%20with%20backslashes%20works%20correctly%20directly%20in%20DuckDB%20%28outside%20Superset%29%20to%20isolate%20where%20the%20escaping%20happens%0A-%20Check%20if%20upgrading%20%60duckdb-engine%60%20resolves%20this%2C%20as%20%5Bversion-specific%20issues%20have%20been%20reported%5D%28https%3A//github.com/apache/superset/issues/31978%23issuecomment-2633389243%29%0A%0AFor%20reference%2C%20%5Bsimilar%20escape%20character%20issues%20have%20occurred%20with%20other%20databases%5D%28https%3A//github.com/apache/superset/issues/34342%23issuecomment-3124815510%29%20%28Databricks%2C%20BigQuery%29%20and%20required%20database-specific%20solutions%20like%20custom%20string%20escapers.%20If%20confirmed%20to%20be%20a%20duckdb-engine%20issue%2C%20a%20similar%20fix%20could%20potentially%20be%20implemented%
 
20in%20%5BSuperset%27s%20DuckDB%20engine%20spec%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/db_engine_specs/duckdb.py%29.)&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/38453)


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