rusackas commented on code in PR #43236:
URL: https://github.com/apache/superset/pull/43236#discussion_r4067168503
##########
superset/db_engine_specs/db2.py:
##########
@@ -95,21 +97,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:
Same false positive codeant raised back in August. Db2 LUW has had a native
DATE_TRUNC(part, expr) scalar function since 11.1
(https://www.ibm.com/docs/en/db2/12.1.x?topic=functions-date-trunc), and 10.5,
the last version without it, went end of support in April 2025. Db2 for i is
the one without it, which is exactly why ibmi.py keeps the CAST-based
expressions. Leaving the code as is.
--
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]