Skip to content

fix: filter Sunburst temporal segments by bucket and invert Hours offset in grained filters - #45598

Merged
aminghadersohi merged 10 commits into
apache:masterfrom
aminghadersohi:fix-sunburst-temporal-crossfilter
Oct 22, 2026
Merged

aminghadersohi merged 10 commits into
apache:masterfrom
aminghadersohi:fix-sunburst-temporal-crossfilter

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Sunburst (frontend):

  • Sunburst cross-filters use raw hierarchy values rather than display labels. Known temporal grains select a whole bucket with TEMPORAL_RANGE. Exact matches on physical columns send epoch milliseconds so the backend can produce engine-native timestamp literals; adhoc SQL levels send a naive ISO datetime, because an adhoc expression has no native type to convert an epoch into. Engine-specific grains without frontend bucket arithmetic keep grain on their equality filters.
  • Drill to detail sends the bucket label with == plus grain, which survives the chart/dashboard time_range override.
  • Drill by sends a grained segment as its TEMPORAL_RANGE bucket, like Timeseries Drill by. Drill by converts filters with simpleFilterToAdhoc, which keeps only column, operator and comparator, so a grain would be dropped. Known limitation, shared with Timeseries: a chart or dashboard Time Range replaces that range, and an engine-specific grain without a fixed length matches only the bucket start.
  • The shared getTemporalXAxisDrillByFilter helper (both Timeseries Drill by callers) keeps master's naive ISO datetime for exact matches.
  • Grain detection uses the effective Time Column (dashboard override before saved chart setting). Implicit semantic-view axes require exactly one selected temporal column.
  • Adaptive Month/Quarter labels include the year. Week/Day/Hour and unknown grains keep the regular compact formatter. Date selection keys use epoch milliseconds, with a label-based compatibility fallback; highlighting compares keys level by level.
  • Cross-filter bucket ranges override the target chart's Time Range and other temporal range filters, including filters on other time columns. This mirrors Timeseries behavior.

Grained filters with a dataset Hours offset (backend, superset/models/helpers.py, all charts):

  • Grained bucket comparisons (==, !=, IN, NOT IN, <, <=, >, >=) use the same expression as grouping on engines with SQL temporal-shift support. On engines without it, the display-only Hours offset is removed from each selected bucket value before comparison. An unresolvable dataset timezone falls back to the Hours offset, as pandas does.
  • This changes results, on datasets with an Hours offset, for Drill to detail from Timeseries, Mixed Timeseries, Big Number with trendline, Pivot Table and Sunburst, and for grained cross-filters from Table and AG Grid Table (IN + grain on the time column). It also reverses the behavior pinned by fix(dataset): correct Hours Offset filter bounds and grain-truncation order #43173: test_grained_adhoc_filter_sql_is_unchanged becomes test_grained_adhoc_equality_filter_applies_dataset_offset.

Related: #45571 supplies Sunburst Explore grain controls/query configuration. Landing plan: #45571 lands first; this PR then merges master and adopts its timeGrain.ts. Neither PR's base or ready-for-review state is changed here.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Historical captures below predate this review follow-up; browser acceptance was not rerun. The Drill by request shape changed after these captures (grained segments use a bucket range, exact values an ISO datetime).

Screenshots

Before After
Month-grained temporal ring with the default adaptive date format: labels include the year (Oct 2003 / Oct 2004) instead of two identical 'October' segments
Clicking the Oct 2003 segment cross-filters the other charts to that month (158 rows); before, every target failed with 'invalid input syntax for type timestamp'
Drill by deal_size from an ungrained date segment (2003-11-14): 2 / 19 / 17 rows; before, the query failed on the displayed label
Drill to detail by Oct 2003 on a month-grained ring: 158 rows (new)
Embedded dashboard (guest token): the same Oct 2003 cross-filter, total 158 (new)

Captured at 37e5c78a. Local docker-compose-light env, examples dataset cleaned_sales_data; charts and dashboard created for this check.

Before/after payload evidence: superset-frontend/plugins/plugin-chart-echarts/test/Sunburst/EchartsSunburst.test.tsx expects timestamps instead of formatted names and Month/Year bucket ranges; superset-frontend/plugins/plugin-chart-echarts/test/Sunburst/transformProps.test.ts expects distinguishable year-bearing labels.

TESTING INSTRUCTIONS

Commands run at 62cef72cee285fa71d1b5d43fe44a69ea48422ff:

# From superset-frontend/plugins/plugin-chart-echarts
npx tsc --noEmit
# From superset-frontend
npx jest --runInBand plugins/plugin-chart-echarts src/components/Chart
# In Docker (Python 3.11 image), SUPERSET_TESTENV=true, the checkout's superset/ and tests/ mounted
pytest -n 2 --dist loadfile -q -o addopts="" -m "not manual and not llm_compliance" tests/unit_tests/models/test_hours_offset_bound_truncation.py tests/unit_tests/models/helpers_test.py tests/unit_tests/connectors/sqla/models_test.py
# From repo root, changed files only, ruff 0.9.7
pre-commit run --files <changed files>

Plugin TypeScript: exit 0. Jest: 1615 passed, 1 skipped (123 suites). Docker Python: 881 passed. Pre-commit: exit 0.

superset-frontend/src/components/Chart/DrillBy/DrillByTemporalFilters.test.tsx follows the real Drill by request path: it right-clicks a rendered Sunburst segment, opens DrillByModal with the resulting filters and checks the posted chart-data request after simpleFilterToAdhoc and convertFilter.

Manual verification to repeat: select raw and grained temporal segments; inspect cross-filter and both drill results with a dashboard Time Range, a dashboard Time Column override, two temporal hierarchy levels, adhoc temporal levels, engine-specific grains, and positive/negative dataset Hours offset. Compare bucket counts and row identities rather than just SQL compilation. Live Trino/BigQuery/Snowflake/MySQL execution was not run; the engine-capability tests use SQLite with the SQL-shift flag switched.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 8dcf1a6
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ada8b816eb3a410e46bd37a
😎 Deploy Preview https://deploy-preview-45598--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added doc Namespace | Anything related to documentation plugins risk:chart-metadata labels Oct 22, 2026
A dashboard Time Column filter sets the query granularity through
extraFormData.granularity_sqla, so that level is bucketed by the time
grain. Treat it as grained when building labels and cross-filters.
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.14%. Comparing base (4e5d0ef) to head (8dcf1a6).
⚠️ Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
...plugins/plugin-chart-echarts/src/Sunburst/utils.ts 93.61% 3 Missing ⚠️
superset/models/helpers.py 91.42% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45598      +/-   ##
==========================================
+ Coverage   84.10%   84.14%   +0.03%     
==========================================
  Files        3056     3057       +1     
  Lines      201285   201555     +270     
  Branches    47066    47146      +80     
==========================================
+ Hits       169299   169600     +301     
+ Misses      28747    28710      -37     
- Partials     3239     3245       +6     
Flag Coverage Δ
hive 34.86% <2.85%> (-0.03%) ⬇️
javascript 80.21% <96.70%> (+0.05%) ⬆️
mysql 52.82% <28.57%> (-0.04%) ⬇️
postgres 52.82% <31.42%> (-0.04%) ⬇️
presto 36.60% <20.00%> (-0.02%) ⬇️
python 87.36% <91.42%> (+0.02%) ⬆️
sqlite 52.58% <28.57%> (-0.04%) ⬇️
unit 81.76% <91.42%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Samples queries replace every TEMPORAL_RANGE value with the chart's
time_range, so drilling to detail on a grained segment returned every row
of the dashboard time range. Match the bucket label on the grained column
instead, as Timeseries does.
@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Manual check on a local docker-compose-light env (examples dataset cleaned_sales_data, counts compared with SQL on the same database), head 37e5c78:

  • Cross-filters from the temporal ring now return exactly the bucket: raw 2003-11-14 → 38, Oct 2003 → 158, Nov 2004 → 301, Year 2004 → 1345, temporal outer ring Nov 2003 → 296, dashboard Time column + Time grain = Month on an ungrained chart → 158. On master every target failed with invalid input syntax for type timestamp.
  • Categorical rings: same filters and totals as master (967, 1384). Same results for a Gamma user with dataset access and an embedded guest.
  • Month labels include the year (Oct 2003 / Oct 2004); Drill by from an ungrained segment returns 2 / 19 / 17 rows (master: HTTP 400).
  • Drill to detail on a grained segment returned every row of the chart's time range (2823, or 2345 under a dashboard range): samples queries replace TEMPORAL_RANGE values with time_range. Commit 37e5c78 matches the bucket label with its grain instead, as Timeseries does; test drill to detail matches a grained bucket by its label and grain fails before it and passes after; live result 158.
  • Still open, not changed here: a grained Drill by has the same time_range problem (2823 / 2345 instead of 158). Timeseries x-axis Drill by on master does the same, so it needs a fix in the shared drill-by path. Also shared with Timeseries: a cross-filter on a bucket only partly inside the dashboard time range filters targets to the whole bucket.

@aminghadersohi
aminghadersohi marked this pull request as ready for review October 22, 2026 06:00
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 8dcf1a62d00e

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: the fix works for its main case, reuses the shared drill-by helper, and follows the Timeseries cross-filter pattern. But the == temporal filters now send ISO strings instead of epoch values, which bypasses backend timestamp coercion. This PR also conflicts with #45571 on how Drill to detail should work.

🔴 High — Temporal == filters send ISO strings, which skip backend timestamp coercion
getSunburstDetailFilter (Sunburst/utils.ts:107-115) and the ungrained path through getSunburstFilter (utils.ts:82) produce val: '2003-11-14T00:00:00' from getTemporalXAxisDrillByFilter. The old Drill to detail code sent the raw epoch records[i]. filter_values_handler.handle_temporal_value (superset/models/helpers.py:4181-4186) only turns numbers or digit-only strings into engine-native literals via convert_dttm. An ISO string goes through as a plain varchar literal. That works on Postgres, but strictly typed engines such as Trino/Presto reject timestamp = varchar. So a right-click Drill to detail that worked before now errors there. Timeseries Drill to detail sends the raw number together with grain (EchartsTimeseries.tsx:637-640). Fix: for == temporal filters, keep val: value (the raw record) and add grain when the level is grained. Keep ISO strings only inside TEMPORAL_RANGE values.

🟡 Medium — This PR and #45571 disagree on grained Drill to detail and will conflict
This PR uses == plus grain because samples queries overwrite TEMPORAL_RANGE. #45571 uses TEMPORAL_RANGE because equality on a truncated column skips the dataset Hours offset. That concern is real: the grain filter path calls get_timestamp_expression without apply_dataset_offset, while the ring's grouping applies it. So with an offset, the Drill to detail row count can differ from the segment value. Both PRs also add test/Sunburst/EchartsSunburst.test.tsx as a new file (an add/add conflict) and edit the same contextmenu block and docs paragraph. #45571's isGrainedLevel is also already drifting from getSunburstTimeGrain. Fix: agree on one Drill to detail approach and one shared "is this level grained" helper used by both buildQuery and the click handlers, then stack one PR on the other.

🟡 Medium — Grain detection ORs the saved and dashboard time columns instead of using the effective one
getSunburstTimeGrain (utils.ts:40-44) treats a column as grained if it matches temporalColumnsLookup, granularitySqla or extraFormData.granularity_sqla. The backend grains only the effective granularity, where the dashboard value wins. Failure case: a chart with granularitySqla=d1, on a dashboard whose Time Column filter is set to d2. The backend returns raw d1 values, but the chart labels d1 segments "Oct 2003" and a click emits a whole-month range for what is a single day. The temporalColumnsLookup branch also grains every temporal level, while the semantic-view mapper only grains when there is exactly one temporal column. Fix: compare against extraFormData.granularity_sqla ?? granularitySqla, and add a test with two temporal levels.

🟡 Medium — Grains the frontend doesn't know silently match only the bucket start
For engine grains missing from TimeGranularity, getTimeBucketRange returns undefined. Examples: PT6H, PT5S, PT30S, PT0.5H, P0.25Y and TIME_GRAIN_ADDONS grains. getSunburstFilter then falls back to == on the raw column with no grain (utils.ts:73-82). The cross-filter targets get only the rows exactly at the bucket start, with no error. The label formatter also falls back to a full-day range, e.g. "2024-10-07 06:00:00 — 2024-10-07 23:59:59" for PT6H. Fix: when a grain is set but has no computable range, emit {op: '==', val: raw, grain} and keep the regular formatter.

🟡 Medium — Drill by bucket is overwritten when the query has a time_range
Drill by keeps the grained TEMPORAL_RANGE filter (EchartsSunburst.tsx:148-157). _apply_filters (query_context_factory.py:446-455) replaces every TEMPORAL_RANGE value with query_object.time_range. So on a dashboard with a time filter, Drill by from "Oct 2003" shows the whole dashboard range under an "Oct 2003" breadcrumb. Before, the query errored; now the wrong data is silent. Timeseries x-axis Drill by has the same behaviour, but this PR avoids exactly this for Drill to detail. Fix: use the same == plus grain filter for Drill by, or document this as a known limitation in the PR.

🟢 Low — The smart_date label change covers every grain, not just Month/Year
transformProps.ts:309-313 uses getTimeFormatterForGranularity, which returns a range formatter. Week labels become "2024-10-07 — 2024-10-13", which is long for a ring, and Day/Hour labels become full dates. Because categoricalColorScale is keyed by the label, saved label_colors keyed to the old labels also stop applying. Fix: use getSmartDateFormatter(grain) / getTooltipTimeFormatter from utils/formatters.ts, or limit the override to MONTH/QUARTER/YEAR. Then update the description and docs.

🟢 Low — Selection keys for temporal levels aren't backward compatible or timezone-stable
getSunburstSelectionKey (utils.ts:55-60) uses String(value). Temporal cross-filters saved before this change (label-based selectedValues in permalinks or dashboard state) no longer match any node, so the chart renders dimmed until the filter is cleared. For Date records, String(date) depends on the viewer's timezone. Fix: use date.getTime() for Date values; optionally fall back to matching on the label.

🟢 Low — time_range on the cross-filter narrows unrelated time filters on target charts
EchartsSunburst.tsx:95-98 mirrors Timeseries. The backend applies time_range to every TEMPORAL_RANGE filter on the target, including other columns and charts on datasets without this column, and it overrides the dashboard's native Time Range. Since this follows the Timeseries pattern, it's fine to keep, but it's worth one sentence in the docs.

🟢 Low — Docs paragraph is in the wrong section
The Sunburst cross-filter paragraph (exploring-data.mdx:499-502) sits under "Downloading Drill to Detail and Drill By Results". It belongs with cross-filtering. "Exclusive upper bound" also reads like an implementation detail.

🟢 Low — Test gaps
The YEAR case in transformProps.test.ts:111 also passes on master. Nothing covers week/day/hour labels, unknown grains, two temporal levels, effective time-column precedence, or the Hours offset. getSunburstDetailFilter builds a range filter and then throws it away; grain ? {col, op: '==', val, grain} : getSunburstFilter(...) would be clearer.

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

@rebenitez1802 I pushed 81df187 with the following changes for the body-only review:

  1. Epoch equality values: fixed. Sunburst equality filters retain raw epochs; Date values serialize as milliseconds. The shared temporal helper also returns numeric equality values, including its Timeseries callers. Regression: ungrained drill to detail keeps the epoch value for native engine coercion in superset-frontend/plugins/plugin-chart-echarts/test/Sunburst/EchartsSunburst.test.tsx.
  2. Drill design / Hours offset: both Sunburst drill actions use raw == plus grain, without constructing and discarding a range. The backend applies dataset offset before truncation for grained comparisons on engines supporting SQL temporal shifts, including physical columns, inline adhoc columns, and adhoc labels. Regressions: test_grained_drill_equality_returns_the_segment_rows_with_hours_offset and test_grained_drill_filter_by_adhoc_label_applies_hours_offset in tests/unit_tests/models/test_hours_offset_bound_truncation.py; these check actual row identities/counts with positive and negative offsets. Remaining: stacking with fix(sunburst): keep the saved time grain in Explore #45571 and adopting getSunburstTimeGrain in its buildQuery are not complete. I sent the sibling worker this head and the merge-first/shared-helper plan; I did not modify that branch.
  3. Effective Time Column: fixed. Dashboard granularity takes precedence; implicit semantic graining requires exactly one selected temporal level. Regressions in superset-frontend/plugins/plugin-chart-echarts/test/Sunburst/utils.test.ts: does not grain ambiguous semantic hierarchies with two temporal levels and dashboard time column takes precedence in a two-temporal-level hierarchy.
  4. Unknown grains: fixed in the shared fallback: numeric == plus grain, with the regular label formatter. The six engine/addon grain cases in Sunburst test preserves the engine grain %s for cross-filter and drill equality cover both drill actions and cross-filtering. Timeseries caller regression: temporal drill by preserves native epoch coercion and fallback grain %s in superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/EchartsTimeseries.test.tsx.
  5. Drill by time-range overwrite: fixed for Sunburst using the same equality-plus-grain helper as Drill to detail. Regression: drill by preserves a grained bucket when the chart has a time range. Remaining: the pre-existing Timeseries known-grain range behavior is unchanged and documented in the description.
  6. Label scope: restricted the adaptive override to Month/Quarter/Year; Week/Day/Hour and unknown grains retain their compact formatter. Regression: keeps compact smart_date labels for %s in superset-frontend/plugins/plugin-chart-echarts/test/Sunburst/transformProps.test.ts. I updated the description and docs.
  7. Selection keys: Date keys use getTime(); unchanged legacy display-label keys remain selectable/highlighted. Regressions: Date selection keys use epoch milliseconds and legacy label-based temporal selections remain highlighted and click to clear. The compatibility fallback matches unchanged labels, not old month/quarter labels that were reformatted.
  8. Cross-filter Time Range side effects: documented that bucket ranges replace the target Time Range and affect its other temporal range filters, including other time columns.
  9. Docs placement: moved the paragraph to a dedicated Sunburst cross-filtering section and removed the upper-bound implementation detail.
  10. Test gaps / helper clarity: added the cases above, Quarter coverage, and the Hours-offset execution regressions. The Year label case remains a preservation check, not evidence for the label change. The drill helper constructs equality directly.

Fail-before/pass-after proof: with source temporarily restored to reviewed head 37e5c78a8617b5ca52b73e172ba12673f03f2e93, the final Jest run had 26 failures and the focused Hours-offset run had 7 failures. After restoring the implementation: 84 Jest tests passed (5 suites) and 432 Docker Python tests passed across the offset, helpers, and SQLA-model suites. Scoped pre-commit passed, including TypeScript, mypy, ruff, and pylint. Browser acceptance was not rerun.

Siblings checked:

  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/utils.ts — fixed in 81df187
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx — fixed in 81df187
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts — fixed in 81df187
  • superset-frontend/plugins/plugin-chart-echarts/src/utils/xAxisDrillByFilter.ts — fixed in 81df187
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:685 — fixed in 81df187
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:702 — fixed in 81df187
  • superset/models/helpers.py:5343 — fixed in 81df187
  • superset/models/helpers.py:5382 — fixed in 81df187
  • superset/models/helpers.py:5416 — fixed in 81df187
  • superset/common/query_context_factory.py:448 — not affected: only rewrites TEMPORAL_RANGE, while both Sunburst drill actions emit equality
  • superset/connectors/sqla/models.py:1322 — not affected: existing SQL-shift capability/timezone guards remain intact, and temporal range bounds retain their separate offset handling
  • superset/semantic_layers/mapper.py:1280 — not affected: the existing single-temporal-axis rule is mirrored by the frontend helper
  • superset/charts/data/api.py:228 — not affected: delegates canonical QueryObjects to the shared datasource path exercised by the Python execution regressions
  • superset/mcp_service/chart/chart_helpers.py:1312 — not affected: uses QueryContextFactory rather than a separate Sunburst click-filter serializer
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/buildQuery.ts — not affected: this head has no custom grain-detection branch; sibling adoption remains listed above

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

@rebenitez1802 I need to correct two claims in my earlier reply: #45598 (comment)

  • My TypeScript-pass claim was wrong. At 81df187b05fcfe51bf40ac3bea4a46a6213c8e51, npx tsc --noEmit -p plugins/plugin-chart-echarts/tsconfig.json reproduced transformProps.ts(318,22): error TS2345: Argument of type 'TimeGranularity' is not assignable to parameter of type '"P1M" | "P3M" | "P1Y"'.
  • The Hours-offset change covered only SQL-shift-capable engines. I should have explicitly listed the other engines' grained drill mismatch under Remaining.

Fixed in cfb96054943cbcba14b900bf17c838b4e943a38f:

  1. The Month/Quarter/Year label check uses a type-safe comparison, without an assertion or suppression.
  2. Grained equality filters on the non-SQL-shift path subtract the pandas-only Hours offset from the selected bucket before native timestamp coercion. SQL-shift-capable engines retain their existing shifted grouping/comparison expressions. Dataset timezone takes precedence over Hours offset. Adhoc aliases that receive no pandas normalization are left unshifted, rather than subtracting an offset they never received.

Regression test: tests/unit_tests/models/test_hours_offset_bound_truncation.py::test_grained_drill_matches_every_bucket_with_hours_offset covers both capability flags, offsets 0, +1, -1, +25, -25, physical names, verbose names, __timestamp, inline adhoc columns, and adhoc labels. It compares every returned bucket's count and row identities, including midnight-boundary rows. test_grained_drill_with_dataset_timezone_ignores_hours_offset pins the timezone guard; test_display_only_bucket_offset_value_formats covers value formats and null/invalid inputs.

Fail-before/pass-after: with the pre-fix 81df187b05fcfe51bf40ac3bea4a46a6213c8e51 backend source mounted over the final tests, the matrix plus timezone tests reported 16 failed, 38 passed, 67 deselected. All 16 failures were nonzero-offset, SQL-shift-disabled physical/verbose/__timestamp/inline-adhoc cases. The same tests pass with this commit; the full Docker run below includes them and the flag-on regressions.

Commands/results at this head:

# superset-frontend
npx tsc --noEmit -p plugins/plugin-chart-echarts/tsconfig.json
# no diagnostics; exit 0
npx jest --runInBand --verbose plugins/plugin-chart-echarts/test/Sunburst plugins/plugin-chart-echarts/test/utils/xAxisDrillByFilter.test.ts plugins/plugin-chart-echarts/test/Timeseries/EchartsTimeseries.test.tsx
# Test Suites: 5 passed, 5 total; Tests: 84 passed, 84 total; exit 0
# Docker, SUPERSET_TESTENV=true, mounted checkout, container pr45598-ci
pytest -n 2 --dist loadfile --cache-clear -q -o addopts="" tests/unit_tests/models/test_hours_offset_bound_truncation.py tests/unit_tests/models/helpers_test.py tests/unit_tests/connectors/sqla/models_test.py -m "not manual and not llm_compliance"
# 495 passed in 31.33s; exit 0
pre-commit run --files $(git diff --name-only origin/master...HEAD)
# exit 0; Type-Checking (Frontend), mypy (main), and all applicable hooks Passed.
# Hooks reporting no matching files were Skipped, not counted as passed.

The first pre-commit attempt failed on formatting and a test typing error; the quoted result is the rerun after those corrections.

Siblings checked:

  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts:313 — fixed in cfb9605
  • superset/models/helpers.py:4147 — fixed in cfb9605
  • superset/models/helpers.py:5366 — fixed in cfb9605
  • superset/models/helpers.py:5444 — fixed in cfb9605
  • superset/models/helpers.py:5410 — not affected: unknown adhoc aliases have no pandas Hours offset; the matrix pins their unchanged bucket/count behavior with both capability flags
  • superset/models/helpers.py:4225 — not affected: TEMPORAL_RANGE returns before the equality-value adjustment; existing range-bound tests pass
  • superset/connectors/sqla/models.py:1398 — not affected: the SQL-shift-enabled grouping path is unchanged and covered by the flag-on matrix and existing offset tests
  • superset/connectors/sqla/models.py:2275 — not affected: adhoc SQL-shift grouping retains its existing capability/timezone guards
  • superset/db_engine_specs/base.py:579 — fixed in cfb9605
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:141 — not affected: Drill to detail already emits epoch equality plus grain and reaches the corrected backend
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:151 — not affected: Drill by uses the same equality serializer and backend path
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:685 — not affected: fallback equality reaches the shared backend; known-grain ranges remain unchanged
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:702 — not affected: the second shared-helper caller retains the same serialization; Timeseries Jest tests pass
  • superset/common/query_context_factory.py:448 — not affected: only TEMPORAL_RANGE is rewritten by time_range; equality is preserved
  • superset/common/query_context_processor.py:549 — not affected: sync/async query consumers delegate to the same datasource result builder
  • superset/charts/data/api.py:228 — not affected: authorized chart requests use QueryContext and the shared datasource filter builder
  • superset/mcp_service/chart/chart_helpers.py:1312 — not affected: builds QueryContext rather than a separate filter implementation
  • superset/mcp_service/dashboard_scope_sql.py:406 — not affected: its ungrained direct coercion call retains the default zero adjustment
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/buildQuery.ts — not affected: no custom grain-selection branch exists at this head; sibling integration remains below

Remaining: stacking with #45571 and adopting getSunburstTimeGrain in its buildQuery are not complete. I did not change that branch.

Remaining: the pre-existing Timeseries known-grain Drill by range/time_range behavior is unchanged. Browser acceptance and live Trino/BigQuery/Snowflake/MySQL execution were not run; the non-SQL-shift regression executes SQLite with the capability explicitly disabled.

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: thanks for the thorough round. Points 1, 3, 4, 6, 7, 8, 9 and 10 are fixed. I re-ran the Sunburst, Timeseries and xAxisDrillByFilter Jest suites (84 tests) and test_hours_offset_bound_truncation.py (121 tests) at cfb9605494, and all pass. But the Drill by change from my round-1 suggestion doesn't work end to end: Drill by drops grain before the request is sent. That's my mistake, sorry for sending you down that path.

🔴 High — Drill by drops grain, so a grained bucket matches only its start instant
getSunburstDetailFilter now feeds Drill by {op: '==', val: <epoch>, grain} (EchartsSunburst.tsx:151). But DrillByModal.tsx:244-250 turns every drill-by filter into an adhoc filter with simpleFilterToAdhoc, which keeps only subject/operator/comparator (simpleFilterToAdhoc.ts:88-99). convertFilter then emits {col, op, val}. So right-clicking "Oct 2003" on a Month-grained ring and choosing Drill by sends order_date = <2003-10-01 00:00> with no grain. That returns only rows at exactly midnight on Oct 1. At the previous head, the TEMPORAL_RANGE filter returned the whole month whenever the query had no time_range, so this is a regression from round 1. The new ...(grain && { grain }) in xAxisDrillByFilter.ts:156 is dropped the same way for both Timeseries Drill by callers. The test at EchartsSunburst.test.tsx:219-229 checks context.drillBy.filters[0].grain inside the plugin, so it doesn't catch this. The docs sentence "Drill to detail and Drill by retain the selected bucket" (exploring-data.mdx:500) is not true for Drill by. Fix: go back to the TEMPORAL_RANGE bucket for Drill by and keep the time_range overwrite as a documented limitation (same as Timeseries). Alternatively, carry grain through SimpleAdhocFilter → simpleFilterToAdhoc → convertFilter, which is a shared change better done in its own PR.

🟡 Medium — Epoch values in the shared helper break Timeseries Drill by on adhoc x-axes
getTemporalXAxisDrillByFilter now returns val: bucketLabel.getTime() (xAxisDrillByFilter.ts:155) when there's no grain or the grain is unknown. For an adhoc (custom SQL) column, simpleFilterToAdhoc writes the comparator straight into SQL, giving (expr) = 1785628800000. No backend coercion happens there, and Postgres rejects it with "operator does not exist: timestamp = bigint". On master the ISO string worked. Physical columns are fine only when convert_dttm returns a literal; the base convert_dttm returns None, so engines without an override fall back to the raw integer too. Fix: keep the ISO string for Drill by (the epoch value is needed only for Drill to detail and cross-filters), or have handle_temporal_value fall back to dttm.isoformat(sep=" ") when there's no native type or convert_dttm returns None.

🟡 Medium — The Hours-offset fix only covers == on engines without SQL shift
On Postgres/SQLite, apply_dataset_offset=op != TEMPORAL_RANGE (helpers.py:5375, 5416, 5451) shifts every grained operator. On other engines, the value adjustment is gated on op == utils.FilterOperator.EQUALS (helpers.py:5527). So a Table/AG Grid IN + grain cross-filter on __timestamp (TableChart.tsx:601), on a dataset with an Hours offset, is fixed on Postgres but still matches the wrong buckets on Trino/Snowflake/BigQuery. shift_temporal_value already handles lists. Fix: extend the gate to IN, NOT_IN and NOT_EQUALS, or restrict the SQL shift to EQUALS so both engine groups behave the same.

🟡 Medium — The backend change affects every chart's grained filters; please retitle or split it
The helpers.py change also changes Drill to detail results for Timeseries, BigNumber, Mixed Timeseries and Pivot Table, plus Table/AG Grid IN + grain cross-filters, on any dataset with an Hours offset. They're correctness fixes, but a fix(sunburst) title and description don't mention them. The change also reverses #43173's pinned behaviour: test_grained_adhoc_filter_sql_is_unchanged is renamed to ..._applies_dataset_offset. Fix: split the helpers.py change into its own fix(models) PR and ask @sadpandajoe to review it (they wrote #43173). If you'd rather keep one PR, retitle it and list the affected charts in the description.

🟢 Low — The timezone check doesn't match pandas for an invalid timezone
The value adjustment is skipped whenever get_dataset_timezone() returns anything (helpers.py:5530). Pandas, however, falls back to the Hours offset when the timezone fails to resolve (utils/core.py:2198-2203). So a dataset with a misspelled timezone and an Hours offset gets 0 Drill to detail rows. test_grained_drill_with_dataset_timezone_ignores_hours_offset only uses "UTC". Fix: reuse the same timezone validity check as pandas, or add an invalid-timezone case.

🟢 Low — Legacy label fallback causes false highlighting
transformProps.ts:351 checks filterState.selectedValues[0].includes(...), a substring match on one string. Year labels are digit-only, so they match digits inside the new 13-digit epoch keys. For example, selecting 2004 gives "1072915200000,…", which contains "2000", so the 2000 segment stays lit. This only affects how the chart looks. Fix: split the key on , and compare element by element.

🟢 Low — Ungrained temporal equality with an Hours offset is still off
This happens on every engine and isn't new. Pandas adds the offset to displayed values, but the ungrained filter compares the raw column (the adjustment needs filter_grain). So Drill to detail on an ungrained temporal level silently returns a different row. Fix: mention it under "Remaining" and narrow the docs wording at exploring-data.mdx:500-502.

🟢 Low — Reply says base.py:579 was "fixed", but that file isn't changed
superset/db_engine_specs/base.py:579 is only the supports_temporal_column_shift default, which the new code reads; git diff 37e5c78a86 cfb9605494 doesn't touch it. A nit, just so the record is accurate.

🟢 Low — #45571 coordination is still open
Merging this first and having #45571 import getSunburstTimeGrain is the right order. #45571 also has its own timeGrain.ts with different rules: it grains every temporal level when no time column is set. It also has a broader helpers.py change that would shift TEMPORAL_RANGE + grain twice. That change should be dropped in favour of this one.

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

@rebenitez1802 I found another gap in my previous reply: #45598 (comment)

Fixed in db78e36ce9ec440f47da952356e43b6ae63978c4: grained IN / NOT IN filters now undo the display-only Hours offset for each bucket value on engines without SQL temporal shifting. Searching the other operators found the same issue in !=, >, <, >=, and <=; these use the same adjustment. The ==, SQL-shift-enabled, and dataset-timezone paths retain their behavior.

Regression tests in tests/unit_tests/models/test_hours_offset_bound_truncation.py:

  • test_grained_drill_matches_every_bucket_with_hours_offset: all eight comparisons, offsets 0, +1, -1, +25, -25, both capability flags, physical/verbose/__timestamp/inline-adhoc/adhoc-label paths. Filters consume actual P1D grouped bucket values; assertions check counts and row identities, not just generated SQL.
  • test_grained_membership_filter_shifts_each_bucket_value: two nonadjacent buckets plus NULL, IN and NOT IN, offsets +1 and -1, both flags; checks included/excluded timestamps and NULL handling.
  • test_grained_drill_with_dataset_timezone_ignores_hours_offset: expanded to IN / NOT IN as timezone-precedence controls.

Fail-before/pass-after (Docker, same tests with helpers.py from cfb96054943cbcba14b900bf17c838b4e943a38f): matrix/timezone selection reported 96 failed, 316 passed, including IN and NOT IN at both +1 and -1 with SQL shifting disabled. The multi-value test reported 4 failed, 4 passed; all four failures were the capability-disabled cases. With the changed helper, the full three-file run reported 861 passed, 3817 warnings in 28.71s, exit 0.

Commands/results:

# Docker pr45598-python, SUPERSET_TESTENV=true, checkout source/tests copied in
pytest -n 2 --dist loadfile --cache-clear -q -o addopts="" tests/unit_tests/models/test_hours_offset_bound_truncation.py tests/unit_tests/models/helpers_test.py tests/unit_tests/connectors/sqla/models_test.py -m "not manual and not llm_compliance"
# 861 passed; exit 0
# Fail-before selections: -k "matches_every_bucket or dataset_timezone_ignores"
# and -k membership_filter_shifts_each_bucket_value
# From superset-frontend
npx jest --runInBand plugins/plugin-chart-echarts/test/Sunburst plugins/plugin-chart-echarts/test/utils/xAxisDrillByFilter.test.ts plugins/plugin-chart-echarts/test/Timeseries/EchartsTimeseries.test.tsx
# Test Suites: 5 passed, 5 total; Tests: 84 passed, 84 total; exit 0
pre-commit run --files $(git diff --name-only origin/master...HEAD)
# exit 0; applicable hooks Passed, including mypy and frontend type-checking

Initial test-setup/type-check iterations were corrected before the quoted final runs. I removed the test containers with docker rm -fv; docker ps -a --filter name=pr45598 returned only the header.

Siblings checked:

  • superset/models/helpers.py:5522 — fixed in db78e36
  • superset/models/helpers.py:4259 — not affected: the existing list loop already applies the offset inversion per operand; the corrected caller guard enables it for membership filters
  • superset/models/helpers.py:5366 — not affected: inline adhoc grain resolution reaches the shared guard; the expanded matrix pins all eight comparisons
  • superset/models/helpers.py:5410 — not affected: adhoc aliases absent from dataset datetime metadata have no pandas offset to invert; label controls pass
  • superset/models/helpers.py:5444 — not affected: physical, verbose-name, and __timestamp expression resolution reaches the shared guard; each is covered by the matrix
  • superset/models/helpers.py:4225 — not affected: TEMPORAL_RANGE bypasses operand shifting and retains its separate time-bound adjustment; existing range tests pass
  • superset/models/helpers.py:5698 — not affected: null checks have no bucket operands; LIKE/ILIKE patterns are not bucket literals; boolean and array operators are not temporal bucket comparisons and are excluded from the adjustment
  • superset/connectors/sqla/models.py:1398 — not affected: SQL-shift grouping is unchanged; flag-on matrix cases pass
  • superset/connectors/sqla/models.py:2275 — not affected: adhoc SQL-shift grouping retains its capability/timezone guards; inline/label controls pass
  • superset/db_engine_specs/base.py:579 — not affected: unchanged declaration of supports_temporal_column_shift = False, not a fix in cfb9605; git diff 81df187 HEAD -- superset/db_engine_specs/base.py is empty, correcting my previous sibling entry
  • superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:599 — not affected: its grained IN serialization is valid and reaches the corrected backend; __timestamp matrix cases pin that payload shape
  • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/getCrossFilterDataMask.ts:70 — not affected: both single-cell and grouped-row grained IN serializers reach the corrected backend; single/multi-value regressions cover those shapes
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:141 — not affected: both drill actions already emit equality plus grain; equality controls and Sunburst Jest pass
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:685 — not affected: fallback equality reaches the shared backend; known-grain range behavior is unchanged
  • superset/common/query_context_factory.py:448 — not affected: only TEMPORAL_RANGE is rewritten by time_range, not the comparisons changed here
  • superset/mcp_service/dashboard_scope_sql.py:406 — not affected: this other filter_values_handler caller is ungrained and leaves temporal_offset_hours at its zero default

Remaining:

  • Stacking with fix(sunburst): keep the saved time grain in Explore #45571 and adopting getSunburstTimeGrain in its buildQuery are not implemented here; that branch was not changed.
  • The existing Timeseries known-grain range/time_range overwrite limitation is unchanged.
  • Live external-engine/browser acceptance was not run; the capability-disabled path was executed using SQLite with supports_temporal_column_shift explicitly set to False. No real-LLM checks were run.

The horizontal time-axis path calls the same temporal drill helper as the vertical path. Ungrained equality filters intentionally use epoch milliseconds so the backend can coerce native timestamp literals; formattedVal remains the ISO display label.
Drill by converts filters to adhoc filters that keep only column,
operator and comparator, so an equality filter's grain never reached the
query. A grained Sunburst segment now drills by its TEMPORAL_RANGE
bucket, like Timeseries. The shared x-axis helper sends the naive ISO
datetime again: adhoc expressions and labels write the comparator into
SQL without coercion, where an epoch integer fails on typed engines.
Sunburst cross-filters and Drill to detail keep epochs for physical
columns and use ISO datetimes for adhoc levels.

Segment highlighting compares selection keys level by level, so a year
label no longer matches digits inside an epoch key.
normalize_dttm_col falls back to the Hours offset when the dataset
timezone does not resolve, and the SQL temporal shift is skipped for any
configured timezone. Grained bucket filters now invert the display-only
offset in that case on every engine instead of matching nothing.
@aminghadersohi aminghadersohi changed the title fix(sunburst): filter temporal segments by raw bucket values fix: filter Sunburst temporal segments by bucket and invert Hours offset in grained filters Oct 22, 2026
@aminghadersohi

Copy link
Copy Markdown
Contributor Author

@rebenitez1802 Follow-up to review #45598 (review), at head 62cef72. "Fail before" below means the test fails with the source files from 9e35745 (the reviewed head plus one test-only commit) and passes at the fixing commit.

🔴 Drill by drops grain — fixed in 4e8c60e. I took your first fix: Sunburst Drill by sends a grained segment as its TEMPORAL_RANGE bucket (new getSunburstDrillByFilter). Drill to detail keeps == + grain, which goes to the backend without simpleFilterToAdhoc. The docs now state the Time Range override and the start-instant match for engine-specific grains, as for Timeseries.
Regression tests (fail before / pass after):

  • superset-frontend/src/components/Chart/DrillBy/DrillByTemporalFilters.test.tsx › Sunburst Drill by on a grained segment queries the whole bucket. It right-clicks a rendered Sunburst, opens DrillByModal with those filters and checks queries[0].filters in the posted chart-data request, after simpleFilterToAdhoc and convertFilter. Before: {col: 'order_date', op: '==', val: 1727740800000}.
  • EchartsSunburst.test.tsx › drill by selects a grained bucket with its TEMPORAL_RANGE, and preserves the engine grain %s for cross-filter and drill equality (6 cases).
    Backend pin (passes on the base too; the backend is unchanged here): test_hours_offset_bound_truncation.py::test_drill_by_bucket_range_returns_the_segment_rows_with_hours_offset executes that range shape on SQLite, with and without SQL shift, for offsets 0/1/-1, and gets each segment's row count.
    DrillByTemporalFilters.test.tsx › Drill by drops the grain of an equality filter pins the shared behavior you described.
    Siblings checked:
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:86 — not affected: the cross-filter (getSunburstFilter) is already a range, sent through extraFormData.
  • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:142 — not affected: Drill to detail (getSunburstDetailFilter) filters reach the backend with grain.
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:685 — fixed in 4e8c60e: the shared helper returns master's clause again, with no grain key; known grains already used a range.
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:702 — fixed in 4e8c60e: same helper, forced-categorical temporal axis.
  • superset-frontend/src/components/Chart/DrillBy/DrillBySubmenu.tsx:156 — not affected: the xAxisFilters merge feeds the same DrillByModal conversion, covered by the request-path test.
  • superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx:264 — not affected: getFiltersFromConfigsByFieldName uses the same simpleFilterToAdhoc conversion.
  • docs/docs/using-superset/exploring-data.mdx — fixed in 4e8c60e.

🟡 Epoch values break Timeseries Drill by on adhoc x-axes — fixed in 4e8c60e. getTemporalXAxisDrillByFilter sends master's naive ISO datetime again, and its tests are back to master's expectations.
Regression tests (fail before / pass after):

  • DrillByTemporalFilters.test.tsx › Timeseries Drill by on an adhoc x-axis label sends an ISO datetime, not an epoch (request path; covers the exact and the engine-grain fallback).
  • test/Timeseries/EchartsTimeseries.test.tsx › temporal drill by compares a naive ISO datetime for grain %s (2 cases).
  • src/Timeseries/EchartsTimeseries.test.tsx › drillBy uses the swapped data index for a horizontal time-based axis and the three getTemporalXAxisDrillByFilter exact-match tests, restored to master.
    Backend evidence (passes on the base too): test_adhoc_label_drill_comparator_is_not_coerced compiles a filter on an adhoc x-axis label: an epoch reaches SQL as = 1785628800000, an ISO value as a quoted literal.
    Siblings checked:
  • Sunburst adhoc temporal levels — fixed in 4e8c60e: cross-filter, Drill to detail and Drill by sent an epoch for an adhoc SQL level too, where target_native_type is None and nothing converts it. They send the ISO datetime; physical columns keep the epoch. Tests: EchartsSunburst.test.tsx › adhoc temporal levels compare a naive ISO datetime, not an epoch integer, and DrillByTemporalFilters.test.tsx › Sunburst Drill by on an adhoc temporal segment writes a quoted ISO datetime (both fail before).
  • superset/models/helpers.py handle_temporal_value, engines whose convert_dttm returns None — not changed. TableColumn.type_generic returns TEMPORAL for every is_dttm column, including BIGINT epoch columns, where the integer must pass through. An ISO fallback there would break those columns, so I took your first option.

🟡 Hours-offset fix only covers == without SQL shift — fixed in db78e36, pushed at 17:13:20Z, 20 s before this review was submitted, so the review text describes cfb9605. The value adjustment gate covers ==, !=, IN, NOT IN, <, <=, >, >=.
Regression tests (fail with cfb9605's helpers.py, pass at db78e36 and at the final head, run in Docker): test_grained_membership_filter_shifts_each_bucket_value (4 of 8 cases fail before) and test_grained_drill_matches_every_bucket_with_hours_offset (96 cases fail before).
Siblings checked:

  • TableChart.tsx:601 (IN + grain on the time column) — fixed in db78e36: the IN / NOT IN cases above.
  • plugin-chart-ag-grid-table/src/utils/getCrossFilterDataMask.ts — fixed in db78e36: same filter shape and backend path.
  • physical, verbose, __timestamp, adhoc and adhoc-label filter paths — fixed in db78e36: each is a parameter of the matrix test.

🟡 Backend change affects every chart's grained filters — partly done, at 62cef72. I retitled the PR to fix: filter Sunburst temporal segments by bucket and invert Hours offset in grained filters. The description lists the affected charts (Drill to detail from Timeseries, Mixed Timeseries, Big Number with trendline, Pivot Table and Sunburst; Table and AG Grid Table grained cross-filters) and names the reversal of #43173. I kept one PR rather than splitting.

🟢 Timezone check doesn't match pandas — fixed in 62cef72. The gate checks whether the timezone resolves (_has_valid_dataset_timezone). With an unresolvable timezone, the SQL shift is skipped on every engine and pandas falls back to the Hours offset, so the bucket value is inverted on both engine groups.
Regression test: test_grained_drill_with_invalid_dataset_timezone_uses_hours_offset (12 cases, all fail before, pass after; Docker).
Siblings checked:

  • superset/connectors/sqla/models.py:1404 and :2280 (SQL shift gates) — not affected: they skip the shift for any configured timezone, which the new gate accounts for.
  • superset/models/helpers.py get_time_filter — not affected: it already falls back to the Hours offset on ZoneInfoNotFoundError.
  • superset/models/helpers.py _collect_dttm_labels / normalize_dttm_col — not affected: unshifted labels get the pandas offset, which the test asserts.

🟢 Legacy label fallback false highlighting — fixed in 4e8c60e. Highlighting compares keys level by level (isSunburstPathSelected): a segment stays lit only when its key is the selected key or one of its ancestors.
Regression test: transformProps.test.ts › a year label is not highlighted by digits inside a selected epoch key (fails before, passes after).
Siblings checked:

  • EchartsSunburst.tsx isCurrentValueSelected — not affected: exact Array.includes on whole keys.

🟢 Ungrained temporal equality with an Hours offset — not fixed. I narrowed the docs at exploring-data.mdx to say so.

🟢 base.py:579 — you are right: superset/db_engine_specs/base.py is not changed in this PR. Line 579 is the supports_temporal_column_shift default that helpers.py reads. My earlier "fixed" for that line was wrong.

🟢 #45571 coordination — open, see Remaining.

Validation at 62cef72: npx tsc --noEmit in the ECharts plugin exit 0; npx jest --runInBand plugins/plugin-chart-echarts src/components/Chart 1615 passed, 1 skipped (123 suites); Docker Python 3.11 pytest -n 2 --dist loadfile on test_hours_offset_bound_truncation.py, helpers_test.py and connectors/sqla/models_test.py 881 passed; changed-file pre-commit with ruff 0.9.7 exit 0.

Remaining:

  • Drill by on a grained segment: a chart or dashboard Time Range replaces the bucket range, and an engine-specific grain matches only the bucket start. Both are shared with Timeseries Drill by; carrying grain through SimpleAdhocFilter → simpleFilterToAdhoc → convertFilter is left for its own PR.
  • Ungrained temporal equality with an Hours offset compares the stored timestamp (not new, every engine).
  • Physical temporal columns on engines whose convert_dttm returns None still receive the epoch integer in Drill to detail and cross-filters, as on master for every chart's Drill to detail.
  • The PR is not split; I have not requested a review from the author of fix(dataset): correct Hours Offset filter bounds and grain-truncation order #43173.
  • fix(sunburst): keep the saved time grain in Explore #45571 lands first. This PR then merges master, adopts its timeGrain.ts (which grains every temporal level when no time column is set), and the stacking resolves the overlapping files. Its broader helpers.py change would shift TEMPORAL_RANGE + grain twice and should be dropped in favour of this one; I have not edited that branch.

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

@rebenitez1802 One more item for Remaining in #45598 (comment), found by an independent check of that reply at head 62cef72: on a dataset with a valid non-UTC timezone (America/Los_Angeles) and an Hours offset of 1, a grained == or IN filter on a one-row day bucket returns 0 rows and the matching NOT IN returns 2 rows instead of 1, with and without the SQL shift. The displayed bucket labels are converted to the local timezone, but the grained comparison value is not converted back to UTC and is not compared against a similarly converted grouping expression. This is pre-existing on master: the merge-base superset/models/helpers.py reproduces the same six failures. It is out of scope for this PR, whose gate only inverts the Hours offset when the timezone is absent or invalid, and it will get its own PR after this one lands.

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: thanks, every round-2 point is fixed. I re-ran the Sunburst, Timeseries, xAxisDrillByFilter and DrillBy Jest suites (130 tests) and the offset/helpers/sqla pytest suites (878 passed; the only failure is a missing sqlalchemy_bigquery in my env) at 62cef72cee.

One non-blocking docs suggestion is inline. It describes a limitation that exists on master too, so it's not a reason to hold the PR.

A correction to my round-2 note: I said the round-1 TEMPORAL_RANGE Drill by "returned the whole month whenever the query had no time_range". That only holds when the chart has no Time Range filter at all, for the reason in the inline comment.

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

@rebenitez1802 thanks for the approval. The one ask in it, the inline docs suggestion on docs/docs/using-superset/exploring-data.mdx, is applied as you worded it in 8dcf1a6; details in #45598 (comment). No code changed in that commit. Noted the correction about the round-1 TEMPORAL_RANGE Drill by.

@aminghadersohi
aminghadersohi merged commit be40309 into apache:master Oct 22, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation plugins risk:chart-metadata size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants