GitHub user dosubot[bot] added a comment to the discussion: The Jinja Templates
dataset macro cannot be used in Oracle.
<!-- Answer -->
This happens because the {{ dataset() }} macro in Superset always generates SQL
with an alias using the AS keyword, like (SELECT ... ) AS dataset_1, regardless
of the database. Oracle does not allow AS for table aliases in subqueries, so
this syntax causes the ORA-00907 error you’re seeing. There’s currently no
built-in workaround or configuration to change this behavior in Superset—the
macro’s aliasing is hardcoded and does not adapt to Oracle’s requirements.
The relevant code is in superset/jinja_context.py, in the dataset_macro
function, which always appends AS dataset_{id} to the generated SQL [(see
source)](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/jinja_context.py).
No Oracle-specific logic exists in the macro or in the Oracle engine spec to
handle this [(see
source)](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/db_engine_specs/oracle.py).
For now, the only workaround is to manually write compatible SQL in SQL Lab
without using the macro. If Oracle support for the macro is critical, a code
change would be needed to make the macro generate the correct aliasing syntax
for Oracle. No recent issues or pull requests address this gap.
<!-- 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/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/271ae27d-52f7-44f7-b345-43fce1c5740b?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
nbsp;[](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/34415)
GitHub link:
https://github.com/apache/superset/discussions/34415#discussioncomment-13939500
----
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]