Repository navigation
fix(db_engine_specs): use fixed Monday week start for Oracle and Impala Week grain - #45858
dhruv-techdev wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45858 +/- ##
==========================================
- Coverage 84.73% 84.73% -0.01%
==========================================
Files 3069 3069
Lines 205781 205792 +11
Branches 48391 48393 +2
==========================================
+ Hits 174368 174377 +9
- Misses 28121 28122 +1
- Partials 3292 3293 +1
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:
|
rebenitez1802
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix! I checked the Impala side against a live Impala 4.5.2: TRUNC(x, 'D') returns the same-or-previous Monday for every date I tried (a 4,000-day sweep). It also works on TIMESTAMP, DATE, STRING and NULL inputs, and 'D' is as old in Impala as 'WW', so older versions are covered too. On Oracle, 'IW' is the ISO Monday and doesn't depend on NLS_TERRITORY. The only subclass is AscendEngineSpec, and it overrides the grains, so it isn't affected. Bonus: time comparison already keys weeks Monday-first (%Y-W%W), so this also fixes misaligned week-over-week joins.
One non-blocking note inline about UPDATING.md. Also, the PR title got truncated ("…Impa…"); it would be worth restoring the full title before merge.
| TimeGrain.HOUR: "TRUNC(CAST({col} as DATE), 'HH')", | ||
| TimeGrain.DAY: "TRUNC(CAST({col} as DATE), 'DDD')", | ||
| TimeGrain.WEEK: "TRUNC(CAST({col} as DATE), 'WW')", | ||
| TimeGrain.WEEK: "TRUNC(CAST({col} as DATE), 'IW')", |
There was a problem hiding this comment.
🟡 Medium: add an UPDATING.md note for the Week regrouping (non-blocking)
This changes how existing Oracle and Impala Week-grain charts are bucketed. Week starts can move by up to 6 days, the 1–2 day stub at year end disappears, and per-bucket totals change. The query cache key doesn't include the generated SQL, so results cached under 'WW' keep being served until their TTL expires. The Db2 week-grain change (#43236) documented the same kind of shift in UPDATING.md.
UPDATING.md isn't part of this diff, so GitHub can't offer an applyable suggestion there. Here is an entry for the ## Next section:
- The `Week` time grain for Oracle (`TRUNC(..., 'IW')`) and Impala
(`TRUNC(..., 'D')`) now always truncates to Monday. Previously `'WW'`
aligned weeks to the weekday of January 1, so the week start changed every
year and each year ended with a 1–2 day stub week. Existing Week-grain charts
on these engines will regroup, and cached results may show the old buckets
until they expire.There was a problem hiding this comment.
Thanks for the thorough review, and for verifying 'D' on a live Impala!
Added your entry to the ## Next section of UPDATING.md in cd1ed69, and merged the latest master to resolve the conflict with the other new entries there. I also restored the full PR title.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…-week-grain # Conflicts: # UPDATING.md
SUMMARY
The
Weektime grain for Oracle and Impala usedTRUNC(..., 'WW'). In both databases,'WW'truncates to the same weekday as January 1st, not to a fixed week start. As a result:2025-12-31gets its own bucket.This PR changes the unit to one that always truncates to Monday, matching the fixed week start used by other engines:
'WW'→'IW'(ISO week).'IW'doesn't depend onNLS_TERRITORY, unlike'D'/'DY'.'WW'→'D'. Impala'sTRUNCdoes not accept'IW';'D'/'DY'/'DAY'truncate to the previous Monday (seeTruncDayOfWeek/StrToTruncUnitinbe/src/exprs/udf-builtins.cc).The change is one line per engine spec, plus a regression test for each that pins the generated SQL.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Oracle Database 23ai Free (

gvenzl/oracle-free:23-slim).BEFORE (WW)is the oldTimeGrain.WEEKexpression andAFTER (IW)is the new one:TESTING INSTRUCTIONS
Unit tests
Both new tests fail on
master('WW'vs'IW'/'D') and pass with this change.Manual check on Oracle
new_weekshould always be a Monday. In the UI, a time-series chart on an Oracle dataset with Time grain = Week should show Monday-aligned buckets and no stub week at year end.ADDITIONAL INFORMATION
Notes for reviewers
'D'is verified against the Impala source; it has not been run on a live Impala instance.UPDATING.mdentry if reviewers consider this a breaking change.