villebro commented on a change in pull request #13233:
URL: https://github.com/apache/superset/pull/13233#discussion_r579628907



##########
File path: superset/viz.py
##########
@@ -1053,6 +1052,15 @@ def query_obj(self) -> QueryObjectDict:
         d = super().query_obj()
         fd = self.form_data
         d["metrics"] = fd.get("metrics")
+        mapping = {
+            "min": "PT1M",
+            "hour": "PT1H",
+            "day": "P1D",
+            "week": "P1W",
+            "month": "P1M",
+            "year": "P1Y",
+        }
+        d["extras"]["time_grain_sqla"] = 
mapping[fd.get("subdomain_granularity", "min")]

Review comment:
       Minor improvement proposal: To make this work for Legacy Druid, we'd 
need to set the `d["granularity"]` property to time grain. so something like 
this:
   ```python
   time_grain = mapping[fd.get("subdomain_granularity", "min")]
   if self.datasource.type == 'druid':
       d["granularity"] = time_grain
   else:
       d["extras"]["time_grain_sqla"] = time_grain
   ```
   (this is super confusing, I know, 🙁  hoping we can get to cleaning this 
inconsistency up this at some point)




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

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