Skip to content

fix(semantic-layers): separate grain and offset time-axis resolvers - #42093

Merged
sadpandajoe merged 1 commit into
masterfrom
claude/master-ci-failure-fix-225ef4
Jul 15, 2026
Merged

sadpandajoe merged 1 commit into
masterfrom
claude/master-ci-failure-fix-225ef4

Conversation

@sadpandajoe

@sadpandajoe sadpandajoe commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

superset/semantic_layers/mapper.py defined _get_time_axis_column twice, with deliberately different semantics:

  • offset resolver (defined first): returns the first temporal column, falling back to the column named in a TEMPORAL_RANGE adhoc filter, so aggregate-only charts that carry the temporal column only in a filter still get offset-aware time bounds. Used by _get_time_filter and _get_group_limit_filters.
  • grain resolver (defined later): only claims an axis when the selected columns contain exactly one temporal dimension, otherwise returns None so the grain path falls back to raw variants instead of guessing. Used by map_query_object and _validate_granularity.

Because both shared the name _get_time_axis_column, the second definition shadowed the first. Two consequences:

  1. mypy failed pre-commit — Name "_get_time_axis_column" already defined [no-redef] — turning the branch red.
  2. Silent regression: the offset call sites resolved to the grain function at runtime, so the time offset / time-comparison bounds were dropped for aggregate-only charts whose temporal column lives only in a TEMPORAL_RANGE filter. The unit test covering that path was already failing but stayed hidden because an unrelated Python 3.10 CI leg errored out first and cancelled the sibling jobs.

This PR renames the grain resolver to _get_grain_time_axis_column and points its call sites (map_query_object, _validate_granularity) at it, leaving the offset resolver under the original name for its call sites. The two duplicated test blocks are reconciled so both resolvers are covered.

TESTING INSTRUCTIONS

pytest tests/unit_tests/semantic_layers/mapper_test.py

185 tests pass. Before this change, test_get_time_axis_column_finds_temporal_in_temporal_range_filter failed (the masked regression) and pre-commit run mypy reported the [no-redef] error; both pass now.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes fix(semantic-layers): consolidate duplicate time-axis helper and tests #42092
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Note on red CI checks: The failing Python 3.10 unit/integration legs on this PR (and the resulting cancellation of the 3.11 / 3.12 legs) are a pre-existing syntaqlite / StrEnum incompatibility unrelated to this change, already tracked separately (#42007 / #42045 / #42058). This PR is intentionally scoped to the mapper.py regression above; the pre-commit check reflects the actual fix here.

Two `_get_time_axis_column` functions coexisted in `mapper.py`: an
offset-oriented resolver (first temporal column, falling back to a
`TEMPORAL_RANGE` adhoc filter so aggregate-only charts still get
offset-aware bounds) and a grain-oriented resolver (only claims an axis
when exactly one temporal column is selected). The second definition
shadowed the first, so:

- mypy failed pre-commit with `Name "_get_time_axis_column" already
  defined [no-redef]`, turning the branch red.
- The offset call sites (`_get_time_filter`, `_get_group_limit_filters`)
  silently ran the grain resolver, dropping the time offset / time
  comparison bounds for aggregate-only charts whose temporal column lives
  only in a `TEMPORAL_RANGE` filter. The unit test covering that path was
  already failing but stayed hidden because an unrelated Python 3.10 CI
  leg errored out first and cancelled the sibling jobs.

Rename the grain resolver to `_get_grain_time_axis_column` and point its
call sites (`map_query_object`, `_validate_granularity`) at it, leaving
the offset resolver under the original name for the offset call sites.
Reconcile the two duplicated test blocks so both resolvers are covered.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bito-code-review

bito-code-review Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f275e6

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 993ddc9..993ddc9
    • superset/semantic_layers/mapper.py
    • tests/unit_tests/semantic_layers/mapper_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.09%. Comparing base (c6da740) to head (993ddc9).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42093      +/-   ##
==========================================
+ Coverage   64.43%   65.09%   +0.66%     
==========================================
  Files        2747     2747              
  Lines      153977   153977              
  Branches    35318    35318              
==========================================
+ Hits        99216   100237    +1021     
+ Misses      52849    51829    -1020     
+ Partials     1912     1911       -1     
Flag Coverage Δ
hive 39.03% <33.33%> (ø)
mysql 57.84% <33.33%> (ø)
postgres 57.90% <33.33%> (?)
presto 41.01% <33.33%> (ø)
python 59.34% <100.00%> (+1.36%) ⬆️
sqlite 57.51% <33.33%> (ø)
unit 100.00% <100.00%> (?)

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.

@mikebridge mikebridge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fixes the naming conflict---lgtm

@sadpandajoe sadpandajoe added the merge-if-green If approved and tests are green, please go ahead and merge it for me label Jul 15, 2026
@yousoph
yousoph self-requested a review July 15, 2026 22:27
@sadpandajoe
sadpandajoe merged commit 6fe4655 into master Jul 15, 2026
66 of 67 checks passed
@sadpandajoe
sadpandajoe deleted the claude/master-ci-failure-fix-225ef4 branch July 15, 2026 22:33
rdg0 pushed a commit to rdg0/superset that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-if-green If approved and tests are green, please go ahead and merge it for me size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(semantic-layers): consolidate duplicate time-axis helper and tests

3 participants