fix(plugin-chart-ag-grid-table): enforce numeric bounds for range (BETWEEN) filters#40607
Conversation
Code Review Agent Run #3b2601Actionable 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 |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40607 +/- ##
=======================================
Coverage 64.03% 64.04%
=======================================
Files 2663 2663
Lines 143619 143630 +11
Branches 33030 33034 +4
=======================================
+ Hits 91973 91985 +12
+ Misses 50044 50043 -1
Partials 1602 1602
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:
|
There was a problem hiding this comment.
Pull request overview
This PR hardens the AG Grid table plugin’s filter-to-SQL conversion for numeric range (inRange → BETWEEN) filters on metrics, to avoid emitting malformed/unquoted SQL when bounds are not valid numbers.
Changes:
- Coerce
inRangebounds to numbers and skip emitting the clause when bounds are not finite numbers. - Add Jest regression tests covering numeric metric ranges and a non-numeric bound case.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/agGridFilterConverter.ts | Updates metric range (BETWEEN) clause generation to coerce bounds to finite numbers and skip invalid ranges. |
| superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/agGridFilterConverter.test.ts | Adds tests ensuring numeric ranges emit BETWEEN and invalid bounds drop the HAVING clause. |
Code Review Agent Run #fde6f8Actionable 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 |
dc6429c to
0f77556
Compare
…ters Range (BETWEEN) filter operands are interpolated into the generated clause without quoting, so they must be finite numbers. Coerce both bounds with Number() and skip the clause entirely if either is not a finite number, rather than passing the raw value through. Adds regression tests covering a metric range filter with numeric bounds (emits the BETWEEN clause) and with a non-numeric bound (no clause). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…rmatting
Number('') coerces to 0, so an empty range bound slipped through the
finite-number guard and produced a BETWEEN clause instead of being dropped.
Add a toFiniteNumber helper that rejects empty/whitespace-only strings
before coercion. Also apply prettier formatting to the test.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ound Hoist IN_RANGE handling out of the filterTo !== undefined guard so a missing or cleared upper bound is dropped instead of falling through to the generic clause and emitting an invalid single-operand BETWEEN. Also reject nullish bounds in toFiniteNumber. Adds a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0f77556 to
8a8d8cd
Compare
|
Bito Automatic Review Skipped – PR Already Merged |
SUMMARY
In the AG Grid table plugin's filter converter, range (
IN_RANGE→BETWEEN) filter operands are interpolated into the generated clause without quoting, so they need to be finite numbers. Previously the rawfilter/filterTovalues were passed straight through, even though the filter value path accepts strings — which could produce a malformed clause if the operands weren't numeric.This coerces both bounds with
Number()and skips the clause entirely when either is not a finite number, so only well-formed numeric ranges are emitted. Valid numeric ranges are unchanged.BEFORE / AFTER
For a metric range filter, the generated
HAVING:revenue BETWEEN <raw> AND <raw>(operands passed through as-is)revenue BETWEEN 10 AND 20); otherwise no clause is generated.TESTING INSTRUCTIONS
Adds two regression tests (numeric bounds → BETWEEN clause; non-numeric bound → no clause). Full file: 47/47 pass.
ADDITIONAL INFORMATION
🤖 Generated with Claude Code