dosubot[bot] commented on issue #29996:
URL: https://github.com/apache/superset/issues/29996#issuecomment-2305393926

   <!-- Answer -->
   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:
   
   1. **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`.
   
   2. **Review the Query**: Make sure the query with the parameter is correctly 
formatted. For example:
       ```sql
       SELECT *
       FROM "sources_v3"
       WHERE "interface_tag_string" like '{{ tag }}'
       ```
   
   3. **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:
       ```python
       try:
           msg = "{error} ({errorClass}): {errorMessage}".format(**payload)
       except KeyError:
           msg = "{error}: {errorMessage}".format(**payload)
       ```
   
   4. **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.
   
   5. **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.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to