apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
60.86k stars 13.18k forks source link

Error: no results to fetch when using SQL_QUERY_MUTATOR like 'SET SESSION AUTHORIZATION <user>;' #29524

Open tooptoop4 opened 2 weeks ago

tooptoop4 commented 2 weeks ago

Bug description

see https://github.com/apache/superset/pull/21645#issuecomment-1493816027 for more details

How to reproduce the bug

see https://github.com/apache/superset/pull/21645#issuecomment-1493816027 for more details

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

dosubot[bot] commented 2 weeks ago

Hey there, @tooptoop4! I'm here to help you with any bugs, questions, or contributions. Just give me a shout if you need anything.

To resolve the "Error: no results to fetch" issue when using SQL_QUERY_MUTATOR with the statement SET SESSION AUTHORIZATION <user>;, you should set the MUTATE_AFTER_SPLIT configuration variable to True. This ensures that the SQL_QUERY_MUTATOR function is applied after the input query is split, allowing the SET SESSION AUTHORIZATION statement to be properly handled.

Here's the relevant configuration snippet:

# A variable that chooses whether to apply the SQL_QUERY_MUTATOR before or after splitting the input query
# It allows for using the SQL_QUERY_MUTATOR function for more than comments
# Usage: If you want to apply a change to every statement to a given query, set MUTATE_AFTER_SPLIT = True
# An example use case is if data has role based access controls, and you want to apply
# a SET ROLE statement alongside every user query. Changing this variable maintains
# functionality for both the SQL_Lab and Charts.
MUTATE_AFTER_SPLIT = True

By setting MUTATE_AFTER_SPLIT to True, the SQL_QUERY_MUTATOR will be applied after the query is split, which should resolve the issue [1][2].

To continue talking to Dosu, mention @dosu.