Skip to content

fix(semantic-layer): support resampling date results without changing raw exports - #46378

Merged
mikebridge merged 6 commits into
apache:masterfrom
mikebridge:fix-semantic-date-resample-20261119
Nov 21, 2026
Merged

mikebridge merged 6 commits into
apache:masterfrom
mikebridge:fix-semantic-date-resample-20261119

Conversation

@mikebridge

@mikebridge mikebridge commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

TL;DR: Semantic DATE axes can be resampled (for example to fill daily gaps) while DATE series labels, raw results and exports without resampling retain their existing date-only format.

Background: Providers return typed Arrow data. Pandas receives DATE values as Python date objects by default, but resampling requires a datetime index after pivoting.

Problem: A semantic time-series chart using a DATE dimension fails with Resample operation requires DatetimeIndex. Converting dates unconditionally would fix that error but change raw XLSX dates into date-and-time cells.

Changes: Cast only Arrow DATE columns selected as a base axis or granularity to timestamps, and only for queries containing a resample operation. Leave DATE-valued series and non-resample conversion unchanged. Add regression, export compatibility and temporal-boundary tests, plus documentation. No provider, database migration or shared resampling change.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: observations on Jan 5 and Jan 7 cannot be resampled.
After: daily zero-fill returns Jan 5/6/7 values 1/0/3. Raw XLSX cells remain YYYY-MM-DD; newly successful resampled exports match ordinary dataset charts (CSV calendar dates, XLSX YYYY-MM-DD HH:MM:SS).

TESTING INSTRUCTIONS

Run the semantic mapper, model, date-result and time-comparison-refusal unit tests together with tests/unit_tests/pandas_postprocessing/test_resample.py.

In a time-series chart using a semantic DATE dimension, request daily resampling with zero fill and verify missing days appear. Export the chart as CSV and XLSX. Repeat without resampling and confirm date-only raw export formatting is unchanged.

Local verification: 744 focused tests pass; changed-file hooks pass. Six DATE-series regression cases fail before narrowing the conversion and pass afterwards. Removing the resample-only gate also produces seven failures in the non-resample export and operation guards; restoring it makes them pass. Verification used offline unit tests, not a live provider or browser session.

ADDITIONAL INFORMATION

NULL time-axis buckets remain unsupported by resampling, matching ordinary datasets; filter them out first. Semantic time comparison remains explicitly refused. Forecasting on a DATE axis remains an existing limitation and is not fixed here.

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

Keep DATE objects for raw and non-resampled results so XLSX date-only formatting is unchanged. Convert typed dates for resample-bearing queries to provide the DatetimeIndex required after pivoting. Cover SQL parity, export bytes, null and empty results, filter bounds, and existing time-comparison refusal.
Cast only base-axis and granularity DATE columns so resampling does not change DATE series labels or exports. Cover date and timestamp axes against ordinary dataset output, consolidate serializer fixtures, and document the separate forecast limitation.
Give raw-export and other-operation queries a temporal axis so the tests catch accidental removal of the resample-only conversion gate.
@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Nov 19, 2026
@mikebridge
mikebridge marked this pull request as ready for review November 19, 2026 19:04
Comment thread superset/semantic_layers/mapper.py Resolved
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; valid BASE_AXIS query objects keep labels aligned with their expressions, and mismatches fail during pivot before resampling.

Assessed commit: e8fbddc7dea9

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.67%. Comparing base (ca9e6d1) to head (e8fbddc).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46378      +/-   ##
==========================================
- Coverage   85.71%   85.67%   -0.05%     
==========================================
  Files        3114     3109       -5     
  Lines      215336   214912     -424     
  Branches    51038    50823     -215     
==========================================
- Hits       184580   184124     -456     
- Misses      27340    27373      +33     
+ Partials     3416     3415       -1     
Flag Coverage Δ
hive 33.98% <12.50%> (-0.01%) ⬇️
mysql 51.65% <12.50%> (-0.01%) ⬇️
postgres 51.68% <12.50%> (-0.01%) ⬇️
presto 35.67% <12.50%> (-0.01%) ⬇️
python 88.32% <100.00%> (+<0.01%) ⬆️
sqlite 51.35% <12.50%> (-0.01%) ⬇️
unit 83.62% <100.00%> (+<0.01%) ⬆️

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.

@aminghadersohi aminghadersohi 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.

The new mapper test reintroduces full-tree mypy errors that master already fixed, and the empty-result test cannot fail.

Narrow semantic filters before checking temporal bounds so full-tree mypy can verify the assertions. Snapshot empty results and assert post-processing is skipped so removing the empty guard fails the regression test.

Addresses review threads 4639084179 and 4639084190 on apache#46378.

@aminghadersohi aminghadersohi 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.

The resample-only DATE-axis cast and both strengthened tests look correct.

@mikebridge
mikebridge merged commit b9c3bd2 into apache:master Nov 21, 2026
84 of 86 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 size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants