Repository navigation
fix(charts): preserve time filter for expression axes - #42052
Vitor-Avila merged 2 commits into
Conversation
Code Review Agent Run #f7fd79Actionable 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42052 +/- ##
==========================================
- Coverage 64.44% 56.21% -8.24%
==========================================
Files 2747 2747
Lines 153874 153878 +4
Branches 35285 35286 +1
==========================================
- Hits 99161 86499 -12662
- Misses 52801 66549 +13748
+ Partials 1912 830 -1082
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:
|
How this change fits into query construction
In this code path, granularity = "event_time"
from_dttm = ...
to_dttm = ...the dataset SQL generator can produce: WHERE event_time >= ...
AND event_time < ...Before this change, This patch adds a narrow fallback. When:
we set the validated main datetime column as the filter subject. The immediate The resulting query keeps the expression in |
Possible future follow-up: validate bounded queries have a time-filter subjectThis PR fixes the concrete normalization gap, but a useful defensive improvement would be to validate normalized The targeted invariant would be:
In that state, the supplied bounds cannot affect the generated SQL. Superset could emit a targeted warning or raise a query-validation error rather than silently executing an unbounded query. A generic check that every This is a suggested future follow-up, not additional scope or a blocker for this PR. |
5915065 to
87a64f4
Compare
|
Potential future follow-up (not a blocker for this PR): when granularity is inferred from It would also be useful for that follow-up to add coverage through the public query-context factory path—not only direct |
|
Bito Automatic Review Skipped – PR Already Merged |
Co-authored-by: Mike Bridge <[email protected]>
…dent fix Master landed its own fix for the same ClickHouse full-table-scan bug (#42052) after this PR was approved, via a differently-guarded `should_infer_filter_granularity` check. This PR's own unguarded `elif` branch would have regressed master's `test_granularity_not_inferred_from_another_temporal_filter` by firing in a case master's guard exists to prevent, so it's dropped in favor of master's check. The one piece master's fix was still missing - a dedupe of a pre-existing TEMPORAL_RANGE filter already on the inferred main_dttm_col, to avoid a duplicate WHERE clause - is ported forward into master's guarded branch instead. Also restores the catalog/schema argument-order fix in datetime_format_detector.py's get_df call, which master's own later ClickHouse read-limit retry refactor had reintroduced. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
SUMMARY
Fixes query construction for charts whose x-axis is an adhoc SQL expression and whose time range comes from dashboard filtering.
Without an explicit granularity, the physical datetime column was not retained as the time-filter subject. On ClickHouse this could produce an effectively unbounded read and trigger
TOO_MANY_ROWS, even though the dashboard supplied a narrow time range. The fix infers the dataset main datetime column only for bounded adhoc expression axes and keeps that inferred value out of the legacy axis-rewrite and temporal-filter-removal path.Regression coverage verifies that the expression remains the grouping dimension, the physical datetime predicate is generated, physical temporal axes are not rewritten, and independent temporal filters are preserved.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
After
Manual browser reproduction for screenshots:
Configure a ClickHouse table containing:
max_rows_to_readsetting.Add the table as a Superset dataset and configure its physical datetime column as the dataset’s main datetime
column.
Create a chart with:
COUNT(*)as the metric.Add the chart to a dashboard and create a native time-range filter targeting the dataset’s main datetime
column.
Select a narrow range whose matching rows are below
max_rows_to_read.On master, refresh the dashboard. The chart fails with ClickHouse
TOO_MANY_ROWSbecause the generatedaggregation does not include the physical datetime predicate.
Switch to this branch and refresh the same dashboard. The chart renders successfully.
Inspect the generated SQL and verify that:
SELECTandGROUP BY.WHERE.TESTING INSTRUCTIONS
Automated:
Expected: 49 tests pass.
Manual ClickHouse reproduction:
max_rows_to_readvalue on the ClickHouse connection.master, refresh the chart and observeTOO_MANY_ROWSbecause the physical time predicate is absent.ADDITIONAL INFORMATION