Repository navigation
fix(explore): apply the dataset timezone to grained temporal filter values - #46175
Conversation
…alues A dataset with a valid non-UTC timezone groups temporal buckets on the stored UTC value, then pandas moves each bucket label into that timezone for display. Grained ==, !=, IN, NOT IN and range comparisons (cross-filters, Drill to detail) sent that local label back unchanged, so they compared a local wall time against a UTC bucket and selected the wrong rows. Convert the label back to UTC before comparing, for every value shape the filter accepts (epoch milliseconds, numeric strings, datetimes, ISO strings). DATE columns, UTC datasets, datasets without a timezone and invalid timezones keep their existing behavior.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #46175 +/- ##
==========================================
- Coverage 85.37% 85.28% -0.09%
==========================================
Files 3098 3090 -8
Lines 213116 212454 -662
Branches 50276 49968 -308
==========================================
- Hits 181938 181186 -752
- Misses 27744 27840 +96
+ Partials 3434 3428 -6
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:
|
|
Product acceptance at 068d155: ship. I ran the PR head in-process against a real PostgreSQL 17 database (2,000 rows, America/Los_Angeles, day grain, 52 buckets:
One LOW note, already listed as a known limitation in the description. On the fall-back DST day, hour grain shows two buckets labelled |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
rusackas
left a comment
There was a problem hiding this comment.
Thanks @aminghadersohi, nice to see the timezone case handled the same way as the Hours offset, and the real-Postgres check against every bucket is reassuring. LGTM!
|
Thanks @rusackas for the review. |
* origin/master: (393 commits) fix(a11y): name the semantic view description input (apache#46458) docs(semantic): explain datasource list modification eligibility (apache#46462) docs(semantic-layer): document NULL-preserving exclusion filters (apache#46447) fix(uploads): skip folder and system entries in columnar ZIP uploads (apache#45617) fix(i18n-es): promote 47 of the zero-context backfill entries (apache#45847) fix(mcp): return structured ChartError on SQLAlchemyError in get_chart_sql (apache#44351) fix(datasets): follow semantic view modification permissions (apache#46448) fix(docker): account for container memory limits in frontend-mem-nag.sh (apache#46373) fix(reports): carry the report's native filters in the email and Slack link (apache#46062) fix(explore): apply the dataset timezone to grained temporal filter values (apache#46175) fix(i18n): enforce the do-not-translate registry across the catalogs (apache#45974) chore(logging): log unparseable virtual dataset SQL at debug in the RLS lookup (apache#46139) fix(i18n): split parameter-suggestion plural into two messages (apache#46049) test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration (apache#46319) perf(dashboard): look up the dashboard once per filter_state read (apache#46314) fix(i18n): load the dayjs locale for every language with a catalog (apache#45982) test(semantic-layer): make date export parametrization deterministic (apache#46449) fix(oauth2): idempotent OAuth2 completion and resilient listener (apache#40292) fix(explore): prevent full table scan when SQL expression is used as x-axis (apache#41339) feat(mcp): radar chart type plugin (apache#43571) ... # Conflicts: # .github/workflows/docker.yml # .github/workflows/superset-frontend.yml
SUMMARY
On a dataset with a valid non-UTC
extra.timezone, temporal buckets are grouped on the stored UTC value and then moved into the dataset timezone for display (normalize_dttm_col). Grained comparisons (==,!=,IN,NOT IN,<,>,<=,>=with a grain, as sent by cross-filters and Drill to detail) sent that displayed local label back unchanged. It was compared against the UTC bucket, so a one-row bucket matched 0 rows for==/IN, andNOT INkept rows it should have excluded. This happens whatever the engine's SQL-shift capability, because a configured timezone disables the SQL shift.filter_values_handleralready inverted the Hours offset for these values; it now takes atemporal_timezoneand converts the label from the dataset timezone back to UTC the same way, for every value shape it accepts (epoch milliseconds, numeric strings, datetimes, ISO strings). Aware values are left alone, as they already name an instant.Unchanged: UTC datasets and datasets with no timezone, invalid timezones (still fall back to the Hours offset), DATE columns (a date has no time of day for the zone to move), ungrained filters and
TEMPORAL_RANGE(already converted inadjust_time_bounds).Known limitation: a label that falls in a DST fold hour maps back to its first occurrence.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A, backend only.
TESTING INSTRUCTIONS
pytest tests/unit_tests/models/test_hours_offset_bound_truncation.pyThe new tests (
test_grained_drill_with_valid_dataset_timezone_matches_displayed_bucket,test_display_only_bucket_timezone_value_formats,test_grained_drill_value_conversion_skips_date_columns) fail onmaster: grained==/IN/NOT IN, two zones, Hours offsets 0/1/-1, both SQL-shift capability modes.Manual: set a dataset's
extrato{"timezone": "America/Los_Angeles"}, chart a grained temporal dimension (for example a Sunburst or Table with Drill to detail), and drill into a day bucket; the rows match the bucket's count.ADDITIONAL INFORMATION