You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "ampil (via GitHub)" <gi...@apache.org> on 2025/03/21 09:22:14 UTC

[D] Querying Superset dataset using jinja [superset]

GitHub user ampil created a discussion: Querying Superset dataset using jinja


I am trying to run a query for saved dataset using jinja in SQL lab. 
I tried:
`select * from {{dataset(115)}}`

I face the error: `oracle error: ORA-00907: missing right parenthesis`

The jinja flag is turned on: `'ENABLE_TEMPLATE_PROCESSING': True,`
The datasource_id = 115 is related with the dataset on the Datasets tab.

My query is simple:
```
SELECT "Name", "Id"   
FROM dbo."Clients"
WHERE "Status" = 1
```

What am I missing? How to run queries like `select * from {{dataset(115)}}` ?

GitHub link: https://github.com/apache/superset/discussions/32788

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


Re: [D] Querying Superset dataset using jinja [superset]

Posted by "imedlee (via GitHub)" <gi...@apache.org>.
GitHub user imedlee added a comment to the discussion: Querying Superset dataset using jinja

The {{dataset()}} macro in Superset always uses the AS keyword to generate SQL with aliases, such as (SELECT...) AS dataset_1, independent of the database. Oracle does not allow AS to use table aliases in subqueries. Therefore, using the {{dataset()}} macro in oracle will result in the ORA-00907 error. https://github.com/apache/superset/pull/34613

GitHub link: https://github.com/apache/superset/discussions/32788#discussioncomment-14066737

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


Re: [D] Querying Superset dataset using jinja [superset]

Posted by "ampil (via GitHub)" <gi...@apache.org>.
GitHub user ampil added a comment to the discussion: Querying Superset dataset using jinja

@dosu, please help.

GitHub link: https://github.com/apache/superset/discussions/32788#discussioncomment-12577664

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


Re: [D] Querying Superset dataset using jinja [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Querying Superset dataset using jinja

<!-- Answer -->
I found a similar unsolved discussion on using SQL templating in datasets, which might be relevant to your issue: [How to use sql templating in dataset](https://github.com/apache/superset/discussions/32215) <sup>[[1]](https://github.com/apache/superset/discussions/32215)</sup>.

Regarding your specific issue with the `ORA-00907: missing right parenthesis` error, it seems like there might be a problem with how the `dataset` function is being used in your Jinja template. The `dataset` function is expected to generate a subquery, and the error might be related to how Oracle handles the generated SQL.

Here are a few things to check and try:

1. **Verify Dataset Configuration**: Ensure that the dataset with ID 115 is correctly configured in Superset, including its columns and any custom SQL expressions.

2. **Check SQL Syntax**: The error message suggests a syntax issue. Ensure that the SQL generated by the `dataset` function is valid for Oracle. You might need to manually inspect the generated SQL to identify any syntax issues.

3. **Test with a Simple Query**: Try running a simpler query without the `dataset` function to ensure that the connection and basic query execution are working correctly.

4. **Review Jinja Context**: Make sure that the Jinja context is correctly set up and that any necessary macros or functions are available.

If these steps don't resolve the issue, you might need to manually construct the SQL query to ensure compatibility with Oracle's syntax requirements.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7528e8ff-00db-433c-99fa-3e350d0d7e76?feedback_type=other)</sup>


GitHub link: https://github.com/apache/superset/discussions/32788#discussioncomment-12577680

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