Closed kalimalrazif closed 3 months ago
The issue you're encountering seems to be related to the handling of SQL templating parameters when saving a dataset. The error trace indicates a problem in the _stream_query
method in the pydruid/db/api.py
file, specifically a KeyError
for the errorClass
key in the payload.
Here are a few steps to address this issue:
Check SQL Templating Configuration: Ensure that SQL templating is correctly configured in your superset_config.py
file. The ENABLE_TEMPLATE_PROCESSING
flag should be set to True
.
Review the Query: Make sure the query with the parameter is correctly formatted. For example:
SELECT *
FROM "sources_v3"
WHERE "interface_tag_string" like '{{ tag }}'
Error Handling in _stream_query
: The error seems to be due to the absence of the errorClass
key in the payload. You might need to handle this case in the _stream_query
method. Here is a potential fix:
try:
msg = "{error} ({errorClass}): {errorMessage}".format(**payload)
except KeyError:
msg = "{error}: {errorMessage}".format(**payload)
Debugging the get_columns_description
Function: The get_columns_description
function in superset/connectors/sqla/utils.py
is where the error is initially raised. Ensure that the query is correctly executed and the cursor fetches the data properly.
Dataset Refresh Command: The RefreshDatasetCommand
class in superset/commands/dataset/refresh.py
is responsible for refreshing the dataset metadata. Ensure that the dataset exists and the user has the necessary permissions.
By addressing these points, you should be able to resolve the issue with saving the dataset containing SQL templating parameters. If the problem persists, further debugging of the specific methods and error handling in the code might be necessary.
To continue talking to Dosu, mention @dosu.
If I run the query with '{{ tag }}' the query does not run.
The query runs with {{ tag }} without quotes
This seems like a duplicate of https://github.com/apache/superset/issues/28600 - let me know if you agree.
Actually, I'll close this as a duplicate of https://github.com/apache/superset/issues/25786... let's take the conversation (and hopefully a solution!) there.
Totally agree :-) Thanks :-)
Bug description
Can't save a Druid query into a Dataset when the query have params.
How to reproduce the bug
Enable SQL templating
Create a query with params:
Run the query works perfectly fine
Try to save a dataset
Screenshots/recordings
The data set never saves, keeps trying to save
Superset version
4.0.2
Python version
Not applicable
Node version
Not applicable
Browser
Chrome
Additional context
This is the log output:
Checklist