rusackas opened a new pull request, #34513:
URL: https://github.com/apache/superset/pull/34513
### SUMMARY
This PR fixes an issue where bar and pie charts fail to render when using
PostgreSQL `INTERVAL` type as a metric.
The root cause was that PostgreSQL returns `INTERVAL` values as Python
`timedelta` objects, which couldn't be properly serialized for chart rendering.
When these values reached the frontend, they were either missing or in a string
format that couldn't be used as numeric metrics.
**Changes:**
- Added `INTERVAL` to PostgreSQL column type mappings, mapping it to
`GenericDataType.NUMERIC`
- Implemented a column type mutator that converts `timedelta` objects to
total seconds (float)
- Added unit tests to verify the conversion works correctly
Fixes #30052
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:**
- Pie chart: Only legend renders, no chart data
- Bar chart: Axes and X-axis labels appear, but no bars are drawn
**After:**
- Both charts render correctly with INTERVAL values displayed as numeric
seconds
### TESTING INSTRUCTIONS
1. Connect to a PostgreSQL database
2. Create a query that uses an INTERVAL column as a metric:
```sql
SELECT category, MAX(duration_interval) as max_duration
FROM your_table
GROUP BY category
```
3. Create a bar or pie chart from this query
4. Set the INTERVAL column as the metric
5. Verify that:
- The chart renders correctly
- Values are displayed as seconds (numeric)
- No errors appear in the console
### ADDITIONAL INFORMATION
- [x] Has associated issue: #30052
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
🤖 Generated with [Claude Code](https://claude.ai/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]