GitHub user joserocha created a discussion: SQL Server query hints
### Bug description
I am trying to create a chart that queries a SQL Server instance. To prevent
excessive resource consumption, I am using the query hint OPTION (MAXDOP 1). It
works perfectly in SqlLab, but when creating the chart, it triggers the
following error:
Data error
Error: (156, b"Incorrect syntax near the keyword 'OPTION'.DB-Lib error message
20018, severity 15:\nGeneral SQL Server error: Check messages from the SQL
Server\n")
Is there anything I can do to overcome this error?
### Screenshots/recordings
2026-03-14 02:09:33,479:WARNING:superset.connectors.sqla.models:Query SELECT
TOP 50
<my_query> OPTION(
MAXDOP 1
)) AS virtual_table ORDER BY [column] DESC on schema None failed
Traceback (most recent call last):
File "/app/superset/connectors/sqla/models.py", line 1659, in query
df = self.database.get_df(
File "/app/superset/models/core.py", line 710, in get_df
self.db_engine_spec.execute(cursor, sql_, self)
File "/app/superset/db_engine_specs/base.py", line 1855, in execute
raise cls.get_dbapi_mapped_exception(ex) from ex
File "/app/superset/db_engine_specs/base.py", line 1851, in execute
cursor.execute(query)
File "src/pymssql/_pymssql.pyx", line 465, in pymssql._pymssql.Cursor.execute
pymssql.exceptions.OperationalError: (156, b"Incorrect syntax near the keyword
'OPTION'.DB-Lib error message 20018, severity 15:\nGeneral SQL Server error:
Check messages from the SQL Server\n")
### Superset version
master / latest-dev
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my
problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [x] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
GitHub link: https://github.com/apache/superset/discussions/38694
----
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]