rusackas commented on code in PR #43236:
URL: https://github.com/apache/superset/pull/43236#discussion_r4086944777


##########
superset/db_engine_specs/ibmi.py:
##########
@@ -28,6 +30,25 @@ class IBMiEngineSpec(Db2EngineSpec):
     engine_name = "IBM Db2 for i"
     max_column_name_length = 128
 
+    _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_ISO({col})-1) 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",

Review Comment:
   Seemingly accurate for TIMESTAMP columns, but this isn't new to this PR. 
These are the old Db2 arithmetic expressions moved verbatim into the IBM i 
spec, which was already inheriting them, so behavior on IBM i is unchanged 
apart from the `DAYOFWEEK_ISO` week fix. Worth a follow-up if someone on Db2 
for i actually hits it, but I'm resolving this one since the PR's merged.



-- 
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]

Reply via email to