-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(api-gateway): make sure DAP works with sql pushdown #9021
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1185,7 +1185,8 @@ class ApiGateway { | |
| let normalizedQueries: NormalizedQuery[] = await Promise.all( | ||
| queries.map( | ||
| async (currentQuery) => { | ||
| const hasExpressionsInQuery = this.hasExpressionsInQuery(currentQuery); | ||
| const hasExpressionsInQuery = | ||
| this.hasExpressionsInQuery(currentQuery); | ||
|
|
||
| if (hasExpressionsInQuery) { | ||
| if (!memberExpressions) { | ||
|
|
@@ -1195,7 +1196,15 @@ class ApiGateway { | |
| currentQuery = this.parseMemberExpressionsInQuery(currentQuery); | ||
| } | ||
|
|
||
| const normalizedQuery = normalizeQuery(currentQuery, persistent); | ||
| let normalizedQuery = normalizeQuery(currentQuery, persistent); | ||
|
|
||
| if (hasExpressionsInQuery) { | ||
| // We need to parse/eval all member expressions early as applyRowLevelSecurity | ||
| // needs to access the full SQL query in order to evaluate rules | ||
| normalizedQuery = | ||
| this.evalMemberExpressionsInQuery(normalizedQuery); | ||
| } | ||
|
|
||
| // First apply cube/view level security policies | ||
| const queryWithRlsFilters = await compilerApi.applyRowLevelSecurity( | ||
| normalizedQuery, | ||
|
|
@@ -1204,17 +1213,18 @@ class ApiGateway { | |
| // Then apply user-supplied queryRewrite | ||
| let rewrittenQuery = await this.queryRewrite( | ||
| queryWithRlsFilters, | ||
| context, | ||
| context | ||
| ); | ||
|
|
||
| if (hasExpressionsInQuery) { | ||
| // applyRowLevelSecurity may add new filters which may contain raw member expressions | ||
| // if that's the case, we should run an extra pass of parsing here to make sure | ||
| // nothing breaks down the road | ||
| if (this.hasExpressionsInQuery(rewrittenQuery)) { | ||
| rewrittenQuery = this.parseMemberExpressionsInQuery(rewrittenQuery); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've not yet checked yet what can But
Schema compiler expects only So, depending on what
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
String member expression would look like something this:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I've removed all my previous comments and just added the |
||
| rewrittenQuery = this.evalMemberExpressionsInQuery(rewrittenQuery); | ||
| } | ||
|
|
||
| return normalizeQuery( | ||
| rewrittenQuery, | ||
| persistent, | ||
| ); | ||
| return normalizeQuery(rewrittenQuery, persistent); | ||
| } | ||
| ) | ||
| ); | ||
|
|
||
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.
Please, add comment about why early/second call is necessary. I'll probably forget about this whole issue next week 😅