mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
Read the user origin specification. (#1541)
This commit is contained in:
parent
3b9f7cb3f1
commit
62987077fa
@ -1805,7 +1805,7 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):
|
||||
# http://druid.io/docs/0.8.0/querying/granularities.html
|
||||
# TODO: pass origin from the UI
|
||||
@staticmethod
|
||||
def granularity(period_name, timezone=None):
|
||||
def granularity(period_name, timezone=None, origin=None):
|
||||
if not period_name or period_name == 'all':
|
||||
return 'all'
|
||||
iso_8601_dict = {
|
||||
@ -1828,6 +1828,10 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):
|
||||
if timezone:
|
||||
granularity['timezone'] = timezone
|
||||
|
||||
if origin:
|
||||
dttm = utils.parse_human_datetime(origin)
|
||||
granularity['origin'] = dttm.isoformat()
|
||||
|
||||
if period_name in iso_8601_dict:
|
||||
granularity['period'] = iso_8601_dict[period_name]
|
||||
if period_name in ('week_ending_saturday', 'week_starting_sunday'):
|
||||
@ -1931,7 +1935,10 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):
|
||||
dimensions=groupby,
|
||||
aggregations=aggregations,
|
||||
granularity=DruidDatasource.granularity(
|
||||
granularity, timezone=timezone),
|
||||
granularity,
|
||||
timezone=timezone,
|
||||
origin=extras.get('druid_time_origin'),
|
||||
),
|
||||
post_aggregations=post_aggs,
|
||||
intervals=from_dttm.isoformat() + '/' + to_dttm.isoformat(),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user