mirror of https://github.com/apache/superset.git
chore: Add Druid SQL timegrains for parity with Druid NoSQL (#15320)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
parent
53aa35177a
commit
accee507c0
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue