fix(datasource): validate expressions through the shared adhoc-expression checks#41427
fix(datasource): validate expressions through the shared adhoc-expression checks#41427sha174n wants to merge 2 commits into
Conversation
…sion checks Route validate_expression through validate_stored_expression so custom expression validation applies the same single-statement / no-set-operation / no-subquery (unless ALLOW_ADHOC_SUBQUERY) parsing policy already used for stored adhoc column and metric expressions, keeping one parsing policy across the query pipeline. Adds regression coverage that the validator rejects sub-queries and set operations before the validation query is built or run.
Code Review Agent Run #157f2aActionable Suggestions - 0Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
The suggestion to add type hints to the newly added test methods is correct, as it aligns with standard Python practices for maintaining type safety in test suites. You can resolve this by adding the Would you like me to apply this change to the other similar test methods added in this PR as well? tests/unit_tests/models/test_validate_expression.py |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41427 +/- ##
==========================================
- Coverage 64.48% 64.45% -0.03%
==========================================
Files 2661 2661
Lines 145642 145664 +22
Branches 33613 33615 +2
==========================================
- Hits 93912 93889 -23
- Misses 50029 50074 +45
Partials 1701 1701
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Review Agent Run #a6eeebActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
SqlaTable.validate_expression(POST/api/v1/datasource/<type>/<id>/validate_expression/) builds its validation query directly from the submitted expression. This routes the expression throughvalidate_stored_expressionfirst, so expression validation applies the same parsing policy already enforced for stored adhoc column and metric expressions: a single statement, no set operations, and no sub-queries unlessALLOW_ADHOC_SUBQUERYis enabled. The result is one consistent parsing policy across the query pipeline.TESTING INSTRUCTIONS
pytest tests/unit_tests/models/test_validate_expression.py— adds coverage that the validator reports a sub-query or set-operation expression as invalid before the validation query is built or run, alongside the existing valid-expression paths.ADDITIONAL INFORMATION