-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
feat: improve adhoc SQL validation #19454
Conversation
@@ -984,15 +992,14 @@ def is_alias_used_in_orderby(col: ColumnElement) -> bool: | |||
|
|||
def _get_sqla_row_level_filters( | |||
self, template_processor: BaseTemplateProcessor | |||
) -> List[str]: | |||
) -> List[TextClause]: |
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.
Not sure why mypy
didn't catch this.
@@ -1420,7 +1441,6 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma | |||
and db_engine_spec.allows_hidden_cc_in_orderby | |||
and col.name in [select_col.name for select_col in select_exprs] | |||
): | |||
validate_adhoc_subquery(str(col.expression)) |
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.
Moved this up, where it's still a string.
b86e904
to
b4cf9d8
Compare
b4cf9d8
to
b6ab91a
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.
Tested to work very nicely except in one edge case (would be great to add a test for that case, too).
d171500
to
b83a64f
Compare
Codecov Report
@@ Coverage Diff @@
## master #19454 +/- ##
=======================================
Coverage 66.57% 66.58%
=======================================
Files 1675 1675
Lines 64092 64107 +15
Branches 6519 6519
=======================================
+ Hits 42672 42684 +12
- Misses 19729 19732 +3
Partials 1691 1691
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
* feat: improve adhoc SQL validation * Small changes * Add more unit tests
* feat: improve adhoc SQL validation * Small changes * Add more unit tests (cherry picked from commit 6828624)
* feat: improve adhoc SQL validation * Small changes * Add more unit tests (cherry picked from commit 6828624)
* feat: improve adhoc SQL validation * Small changes * Add more unit tests (cherry picked from commit 6828624)
🏷️ preset:2022.11 |
* feat: improve adhoc SQL validation * Small changes * Add more unit tests
SUMMARY
Improve the
validate_adhoc_subquery
function.I changed the logic of
insert_rls
. As originally written we'd pass (1) the adhoc SQL, (2) the dataset name and (3) the associated RLS predicate. In order to use it here I modified it to receive (1) the adhoc SQL with the (2) database and (3) schema where it will run. We then parse the adhoc SQL, and for each table found we check if there's an associated RLS rule; if so, we modify the SQL to include the RLS predicate(s).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Updated unit tests, will add more.
ADDITIONAL INFORMATION