GitHub user dosubot[bot] added a comment to the discussion: Column name in x- 
axis not working

<!-- Greeting -->
Hi @anchaldokania! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the 
superset team.

<!-- Answer -->
This issue happens because Superset's SQL parser treats column names with two 
or more spaces as custom SQL fields, which triggers strict validation and the 
error "custom sql fields cannot contain sub-queries"—even if your query doesn't 
actually have a sub-query. This is a known limitation and has been reported by 
other users, especially with MS SQL and MySQL data sources 
[[32879](https://github.com/apache/superset/issues/32879)], 
[[32541](https://github.com/apache/superset/issues/32541)], 
[[33557](https://github.com/apache/superset/issues/33557)].

Workarounds:  
- Quote the column name using your database's syntax (e.g., `[Column  Name]` 
for MS SQL) in the Custom SQL field 
[[32879](https://github.com/apache/superset/issues/32879)].
- Use underscores or another naming convention instead of spaces in your column 
aliases—snake_case works reliably 
[[32541](https://github.com/apache/superset/issues/32541)].
- You can enable the `ALLOW_ADHOC_SUBQUERY` feature flag to bypass the error, 
but this is discouraged due to security risks 
[[32895](https://github.com/apache/superset/discussions/32895)].

There is no config option or documented fix in Superset 4.1.2 for this, but 
maintainers are aware and have linked it to ongoing work (SIP-117), which may 
resolve the issue in newer versions or the master branch 
[[32879](https://github.com/apache/superset/issues/32879)], 
[[33557](https://github.com/apache/superset/issues/33557)]. For now, using 
underscores or quoting the column name is the most reliable workaround.


<!-- 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/9016ea19-a35c-49ff-a17f-289e65db2620?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/9016ea19-a35c-49ff-a17f-289e65db2620?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/9016ea19-a35c-49ff-a17f-289e65db2620?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/9016ea19-a35c-49ff-a17f-289e65db2620?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/9016ea19-a35c-49ff-a17f-289e65db2620?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/9016ea19-a35c-49ff-a17f-289e65db2620?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/9016ea19-a35c-49ff-a17f-289e65db2620?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=github)&
 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/discussions/34695)

GitHub link: 
https://github.com/apache/superset/discussions/34695#discussioncomment-14102525

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


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

Reply via email to