rusackas commented on code in PR #43236:
URL: https://github.com/apache/superset/pull/43236#discussion_r3885480372
##########
superset/db_engine_specs/db2.py:
##########
@@ -95,21 +95,14 @@ class Db2EngineSpec(BaseEngineSpec):
_time_grain_expressions = {
None: "{col}",
- TimeGrain.SECOND: "CAST({col} as TIMESTAMP) - MICROSECOND({col})
MICROSECONDS",
- TimeGrain.MINUTE: "CAST({col} as TIMESTAMP)"
- " - SECOND({col}) SECONDS"
- " - MICROSECOND({col}) MICROSECONDS",
- TimeGrain.HOUR: "CAST({col} as TIMESTAMP)"
- " - MINUTE({col}) MINUTES"
- " - SECOND({col}) SECONDS"
- " - MICROSECOND({col}) MICROSECONDS ",
- TimeGrain.DAY: "DATE({col})",
- TimeGrain.WEEK: "{col} - (DAYOFWEEK({col})) DAYS",
- TimeGrain.MONTH: "{col} - (DAY({col})-1) DAYS",
- TimeGrain.QUARTER: "{col} - (DAY({col})-1) DAYS"
- " - (MONTH({col})-1) MONTHS"
- " + ((QUARTER({col})-1) * 3) MONTHS",
- TimeGrain.YEAR: "{col} - (DAY({col})-1) DAYS - (MONTH({col})-1)
MONTHS",
+ TimeGrain.SECOND: "DATE_TRUNC('SECOND', {col})",
+ TimeGrain.MINUTE: "DATE_TRUNC('MINUTE', {col})",
+ TimeGrain.HOUR: "DATE_TRUNC('HOUR', {col})",
+ TimeGrain.DAY: "DATE_TRUNC('DAY', {col})",
+ TimeGrain.WEEK: "DATE_TRUNC('WEEK', {col})",
+ TimeGrain.MONTH: "DATE_TRUNC('MONTH', {col})",
+ TimeGrain.QUARTER: "DATE_TRUNC('QUARTER', {col})",
+ TimeGrain.YEAR: "DATE_TRUNC('YEAR', {col})",
Review Comment:
Checked this independently: IBM Db2 added a native `DATE_TRUNC(part, expr)`
scalar function matching Postgres semantics in 11.1, and 10.5 (the last version
without it) hit end of support in April 2025. The codebase already handles
older-Db2 quirks via driver choice (see the LIMIT-syntax note on the ibm_db_sa
driver options) rather than branching the generated SQL, so not gating this by
version matches existing convention. Resolving.
--
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]