zhaoyongjie closed pull request #4965: Update Apache Kylin dbengine with
supported week/quarter grains
URL: https://github.com/apache/incubator-superset/pull/4965
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index a718a0d62c..0adf728a25 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -1321,12 +1321,32 @@ class KylinEngineSpec(BaseEngineSpec):
time_grains = (
Grain('Time Column', _('Time Column'), '{col}', None),
- Grain('second', _('second'), 'SECOND({col})', 'PT1S'),
- Grain('minute', _('minute'), 'MINUTE({col})', 'PT1M'),
- Grain('hour', _('hour'), 'HOUR({col})', 'PT1H'),
- Grain('month', _('month'), 'MONTH({col})', 'P1M'),
- Grain('quarter', _('quarter'), 'QUARTER({col})', 'P0.25Y'),
- Grain('year', _('year'), 'YEAR({col})', 'P1Y'),
+ Grain('second', _('second'),
+ 'CAST(FLOOR(CAST({col} AS TIMESTAMP) TO SECOND) AS TIMESTAMP)',
+ 'PT1S'),
+ Grain('minute', _('minute'),
+ 'CAST(FLOOR(CAST({col} AS TIMESTAMP) TO MINUTE) AS TIMESTAMP)',
+ 'PT1M'),
+ Grain('hour', _('hour'),
+ 'CAST(FLOOR(CAST({col} AS TIMESTAMP) TO HOUR) AS TIMESTAMP)',
+ 'PT1H'),
+ Grain('day', _('day'),
+ 'CAST(FLOOR(CAST({col} AS TIMESTAMP) TO DAY) AS DATE)',
+ 'P1D'),
+ Grain('week', _('week'),
+ 'CAST(TIMESTAMPADD(WEEK, WEEK(CAST({col} AS DATE)) - 1, \
+ FLOOR(CAST({col} AS TIMESTAMP) TO YEAR)) AS DATE)',
+ 'P1W'),
+ Grain('month', _('month'),
+ 'CAST(FLOOR(CAST({col} AS TIMESTAMP) TO MONTH) AS DATE)',
+ 'P1M'),
+ Grain('quarter', _('quarter'),
+ 'CAST(TIMESTAMPADD(QUARTER, QUARTER(CAST({col} AS DATE)) - 1, \
+ FLOOR(CAST({col} AS TIMESTAMP) TO YEAR)) AS DATE)',
+ 'P0.25Y'),
+ Grain('year', _('year'),
+ 'CAST(FLOOR(CAST({col} AS TIMESTAMP) TO YEAR) AS DATE)',
+ 'P1Y'),
)
@classmethod
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]