-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Support SET & SHOW commands as read only SQL commands #11868
chore: Support SET & SHOW commands as read only SQL commands #11868
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11868 +/- ##
==========================================
- Coverage 63.78% 63.75% -0.04%
==========================================
Files 927 928 +1
Lines 45006 45059 +53
Branches 4308 4309 +1
==========================================
+ Hits 28708 28728 +20
- Misses 16120 16154 +34
+ Partials 178 177 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
2a68eb4
to
6aad364
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels slightly specific to Hive. Could we move this logic into BaseEngineSpec
by introducing a def is_dml(statement)
or def is_readonly(statement)
, and let the specific db implementation do the parsing?
Sounds good to me, will refactor it |
superset/sql_parse.py
Outdated
def is_unknown(self) -> bool: | ||
return self._parsed[0].get_type() == "UNKNOWN" | ||
|
||
def is_readonly(self) -> bool: | ||
"""Pessimistic readonly, 100% sure statement won't mutate anything""" | ||
return self.is_select() or self.is_explain() | ||
return self.is_select() or self.is_explain() or self.is_set() or self.is_show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious reading this (would have been an issue before this PR) on whether running multiple statements including non-readonly would work well here, as in:
SET foo='bar';
UPDATE {...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mistercrunch this evaluation happens per statement:
https://github.com/apache/incubator-superset/blob/0409b12a55e893d88f6e992a7df247841a2da8f0/superset/sql_lab.py#L164
Otherwise it will be the same problem for SELECT / EXPLAIN queries
6aad364
to
d99c84e
Compare
36a6ca9
to
7194e95
Compare
@villebro what about this solution ? |
7194e95
to
e7668cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions, but looks pretty good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, especially with the tests! 👍
Does this support SET ROLE command with Presto? @bkyryliuk |
SUMMARY
Adds support for the SET and SHOW queries in sqllab for the read only queries example queries are:
etc
related: #11348
TEST PLAN