You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gayathridevi1993 (via GitHub)" <gi...@apache.org> on 2026/04/05 18:40:42 UTC
Re: [D] SQL Server query hints [superset]
GitHub user gayathridevi1993 added a comment to the discussion: SQL Server query hints
This issue is likely related to how Apache Superset wraps the query internally when generating charts.
In SQL Server, the OPTION (MAXDOP 1) query hint must appear at the end of the final SELECT statement. However, Superset wraps the query inside a subquery (virtual table), as seen in the log:
SELECT TOP 50
<your_query> OPTION (MAXDOP 1)
) AS virtual_table
Because of this wrapping, the OPTION clause is no longer at the valid position, which results in the syntax error:
"Incorrect syntax near the keyword 'OPTION'"
### Possible Workarounds
1. Remove OPTION (MAXDOP 1) from the query when using Superset charts
- This is the simplest approach if parallelism is not critical
2. Use a database-level or server-level configuration for MAXDOP
- This avoids the need for query-level hints
3. Create a view or stored procedure in SQL Server
- Apply the query hint inside the view/SP
- Then query the view from Superset without the OPTION clause
4. Check if Superset allows disabling query wrapping for your dataset
- In some cases, using a saved dataset instead of a custom SQL query may help
Summary
The issue is not with SQL Server itself but with how Superset rewrites the query. Since SQL Server does not allow OPTION hints inside subqueries, this leads to the syntax error.
Let me know if this helps or if you need help testing one of the workarounds.
GitHub link: https://github.com/apache/superset/discussions/38694#discussioncomment-16456804
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org