eschutho opened a new pull request, #37111:
URL: https://github.com/apache/superset/pull/37111
### SUMMARY
When a table chart has `show_totals=true` and `time_offsets` enabled (time
comparison), the totals row was showing `null` for the time comparison column
while individual rows displayed correct values.
**Root Cause:**
The totals query has `columns=[]` (no dimension columns), and
`_determine_join_keys` in `superset/models/helpers.py` was trying to create a
join column from the first column of the DataFrame. For totals queries, this
first column is a numeric metric value (e.g., `54211.76`), not a datetime. The
`generate_join_column` function falls back to `str(value)` for non-datetime
values, causing mismatched join keys between the main DataFrame and offset
DataFrame, resulting in the join failing and returning `null`.
**Fix:**
Added a check in `_determine_join_keys` that detects when there are no join
keys AND the first column is not a datetime. In this case, it returns empty
join keys, which triggers the `__temp_join_key__` fallback mechanism in
`_perform_join` that correctly joins single-row aggregate results.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** Summary row shows `0` for the "# Previous" (time comparison)
column
**After:** Summary row correctly shows the summed time comparison value
### TESTING INSTRUCTIONS
1. Create a table chart with:
- At least one metric (e.g., `SUM(cost)`)
- `show_totals` enabled
- Time comparison enabled (e.g., "1 month ago")
- A temporal filter (e.g., `TEMPORAL_RANGE` on a date column)
2. Verify the totals/summary row shows the correct time comparison value
instead of `null` or `0`
3. Run the unit tests:
```bash
pytest tests/unit_tests/common/test_time_shifts.py -v
```
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]