-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(tesseract): default value filters for views (CORE-357) #10892
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
Open
waralexrom
wants to merge
4
commits into
master
Choose a base branch
from
tesseract-default-value-filter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a83f812
feat(tesseract): add default value filter schema for views
waralexrom 367b24a
feat(tesseract): expose view default value filters to Tesseract
waralexrom 25b16fa
feat(tesseract): apply view default value filters in QueryPropertiesC…
waralexrom 3671fb6
test(tesseract): e2e Postgres tests for view default value filters
waralexrom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,15 +187,27 @@ export class YamlCompiler { | |
| for (const p of transpiledFieldsPatterns) { | ||
| const fullPath = propertyPath.join('.'); | ||
| if (fullPath.match(p)) { | ||
| // View default filter `member` / `unless` are member references in | ||
| // the view's own namespace — not Python expressions — so they go | ||
| // through the same f-string path as `values`. The view's | ||
| // `includedMembers` are not resolvable at transpile time, so | ||
| // running them through the Python parser would treat the name | ||
| // as an undefined identifier. | ||
| const isViewFilterMember = /^filters\.\d+\.member$/.test(fullPath); | ||
| const isViewFilterUnless = /^filters\.\d+\.unless$/.test(fullPath); | ||
| if (typeof obj === 'string' && ['sql', 'sqlTable'].includes(propertyPath[propertyPath.length - 1])) { | ||
| return this.parsePythonIntoArrowFunction(`f"${this.escapeDoubleQuotes(obj)}"`, cubeName, obj, errorsReport); | ||
| } else if (typeof obj === 'string' && isViewFilterMember) { | ||
| return this.parsePythonIntoArrowFunction(`f"${this.escapeDoubleQuotes(obj)}"`, cubeName, obj, errorsReport); | ||
|
Comment on lines
+196
to
+201
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. Nit: The } else if (typeof obj === 'string' && (
['sql', 'sqlTable'].includes(propertyPath[propertyPath.length - 1]) ||
isViewFilterMember
)) {
return this.parsePythonIntoArrowFunction(`f"${this.escapeDoubleQuotes(obj)}"`, cubeName, obj, errorsReport);
}Minor readability win — not blocking. |
||
| } else if (typeof obj === 'string') { | ||
| return this.parsePythonIntoArrowFunction(obj, cubeName, obj, errorsReport); | ||
| } else if (Array.isArray(obj)) { | ||
| const treatAsLiteral = | ||
| propertyPath[propertyPath.length - 1] === 'values' || isViewFilterUnless; | ||
| const resultAst = t.program([t.expressionStatement(t.arrayExpression(obj.map(code => { | ||
| let ast: t.Program | t.NullLiteral | t.BooleanLiteral | t.NumericLiteral | null = null; | ||
| // Special case for accessPolicy.rowLevel.filter.values and other values-like fields | ||
| if (propertyPath[propertyPath.length - 1] === 'values') { | ||
| if (treatAsLiteral) { | ||
| if (typeof code === 'string') { | ||
| ast = this.parsePythonAndTranspileToJs(`f"${this.escapeDoubleQuotes(code)}"`, errorsReport); | ||
| } else if (typeof code === 'boolean') { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit (defensive):
prepareViewFiltersrelies on!cube.filtersto skip regular cubes. The Joi schema already preventsfiltersfrom appearing on non-view cubes, so this works in practice. But sinceprepareViewFiltersaccessescube.includedMembers(which isundefinedon regular cubes), an explicitisViewguard here would make the contract clearer and more robust against future schema changes: