korbit-ai[bot] commented on code in PR #34513:
URL: https://github.com/apache/superset/pull/34513#discussion_r2248930164
##########
superset/db_engine_specs/postgres.py:
##########
@@ -238,8 +238,17 @@ class PostgresEngineSpec(BasicParametersMixin,
PostgresBaseEngineSpec):
ENUM(),
GenericDataType.STRING,
),
+ (
+ re.compile(r"^interval", re.IGNORECASE),
+ INTERVAL(),
+ GenericDataType.NUMERIC,
+ ),
)
+ column_type_mutators: dict[Any, Callable[[Any], Any]] = {
+ INTERVAL: lambda v: v.total_seconds() if hasattr(v, "total_seconds")
else v,
+ }
Review Comment:
### Incomplete INTERVAL type handling <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The mutator for INTERVAL type may not handle all valid PostgreSQL interval
values correctly.
###### Why this matters
Some PostgreSQL interval values could be strings or non-standard interval
formats. These would pass through unchanged, potentially causing visualization
issues or errors in bar/pie charts.
###### Suggested change ∙ *Feature Preview*
Add more robust handling for INTERVAL values that could come in different
formats:
```python
column_type_mutators: dict[Any, Callable[[Any], Any]] = {
INTERVAL: lambda v: (
v.total_seconds() if hasattr(v, "total_seconds")
else float(v) if isinstance(v, (int, float))
else 0 if v is None
else utils.parse_postgres_interval_to_seconds(v) if isinstance(v,
str)
else v
),
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/2313e71d-08fa-4c77-9f12-13d429421393/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/2313e71d-08fa-4c77-9f12-13d429421393?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/2313e71d-08fa-4c77-9f12-13d429421393?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/2313e71d-08fa-4c77-9f12-13d429421393?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/2313e71d-08fa-4c77-9f12-13d429421393)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:84a7261e-7765-4300-990d-874873cfa5ac -->
[](84a7261e-7765-4300-990d-874873cfa5ac)
--
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]