This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new accee50  chore: Add Druid SQL timegrains for parity with Druid NoSQL 
(#15320)
accee50 is described below

commit accee507c0819cd0d7bcfb5a3e1199bc81eeebf2
Author: John Bodley <[email protected]>
AuthorDate: Fri Jun 25 07:21:51 2021 -0700

    chore: Add Druid SQL timegrains for parity with Druid NoSQL (#15320)
    
    Co-authored-by: John Bodley <[email protected]>
---
 superset/db_engine_specs/base.py  | 3 +++
 superset/db_engine_specs/druid.py | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index 623faf2..3d288b7 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -85,12 +85,15 @@ QueryStatus = utils.QueryStatus
 builtin_time_grains: Dict[Optional[str], str] = {
     None: __("Original value"),
     "PT1S": __("Second"),
+    "PT5S": __("5 second"),
+    "PT30S": __("30 second"),
     "PT1M": __("Minute"),
     "PT5M": __("5 minute"),
     "PT10M": __("10 minute"),
     "PT15M": __("15 minute"),
     "PT0.5H": __("Half hour"),
     "PT1H": __("Hour"),
+    "PT6H": __("6 hour"),
     "P1D": __("Day"),
     "P1W": __("Week"),
     "P1M": __("Month"),
diff --git a/superset/db_engine_specs/druid.py 
b/superset/db_engine_specs/druid.py
index 3ab2ded..ef699e4 100644
--- a/superset/db_engine_specs/druid.py
+++ b/superset/db_engine_specs/druid.py
@@ -41,17 +41,26 @@ class DruidEngineSpec(BaseEngineSpec):  # pylint: 
disable=abstract-method
     _time_grain_expressions = {
         None: "{col}",
         "PT1S": "FLOOR({col} TO SECOND)",
+        "PT5S": "TIME_FLOOR({col}, 'PT5S')",
+        "PT30S": "TIME_FLOOR({col}, 'PT30S')",
         "PT1M": "FLOOR({col} TO MINUTE)",
         "PT5M": "TIME_FLOOR({col}, 'PT5M')",
         "PT10M": "TIME_FLOOR({col}, 'PT10M')",
         "PT15M": "TIME_FLOOR({col}, 'PT15M')",
         "PT0.5H": "TIME_FLOOR({col}, 'PT30M')",
         "PT1H": "FLOOR({col} TO HOUR)",
+        "PT6H": "TIME_FLOOR({col}, 'PT6H')",
         "P1D": "FLOOR({col} TO DAY)",
         "P1W": "FLOOR({col} TO WEEK)",
         "P1M": "FLOOR({col} TO MONTH)",
         "P0.25Y": "FLOOR({col} TO QUARTER)",
         "P1Y": "FLOOR({col} TO YEAR)",
+        "P1W/1970-01-03T00:00:00Z": (
+            "TIMESTAMPADD(DAY, 5, FLOOR(TIMESTAMPADD(DAY, 1, {col}) TO WEEK))"
+        ),
+        "1969-12-28T00:00:00Z/P1W": (
+            "TIMESTAMPADD(DAY, -1, FLOOR(TIMESTAMPADD(DAY, 1, {col}) TO WEEK))"
+        ),
     }
 
     @classmethod

Reply via email to