betodealmeida commented on a change in pull request #5380: Add time grain
blacklist and addons to config.py
URL:
https://github.com/apache/incubator-superset/pull/5380#discussion_r204508070
##########
File path: superset/db_engine_specs.py
##########
@@ -340,25 +379,17 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
engine = ''
- time_grains = (
- Grain('Time Column', _('Time Column'), '{col}', None),
- Grain('second', _('second'),
- "DATE_TRUNC('second', {col}) AT TIME ZONE 'UTC'", 'PT1S'),
- Grain('minute', _('minute'),
- "DATE_TRUNC('minute', {col}) AT TIME ZONE 'UTC'", 'PT1M'),
- Grain('hour', _('hour'),
- "DATE_TRUNC('hour', {col}) AT TIME ZONE 'UTC'", 'PT1H'),
- Grain('day', _('day'),
- "DATE_TRUNC('day', {col}) AT TIME ZONE 'UTC'", 'P1D'),
- Grain('week', _('week'),
- "DATE_TRUNC('week', {col}) AT TIME ZONE 'UTC'", 'P1W'),
- Grain('month', _('month'),
- "DATE_TRUNC('month', {col}) AT TIME ZONE 'UTC'", 'P1M'),
- Grain('quarter', _('quarter'),
- "DATE_TRUNC('quarter', {col}) AT TIME ZONE 'UTC'", 'P0.25Y'),
- Grain('year', _('year'),
- "DATE_TRUNC('year', {col}) AT TIME ZONE 'UTC'", 'P1Y'),
- )
+ time_grain_functions = {
+ None: '{col}',
+ 'PT1S': "{col}) AT TIME ZONE 'UTC'",
+ 'PT1M': "DATE_TRUNC('minute', {col}) AT TIME ZONE 'UTC'",
+ 'PT1H': "DATE_TRUNC('hour', {col}) AT TIME ZONE 'UTC'",
+ 'P1D': "DATE_TRUNC('day', {col}) AT TIME ZONE 'UTC'",
+ 'P1W': "DATE_TRUNC('week', {col}) AT TIME ZONE 'UTC'",
+ 'P1M': "DATE_TRUNC('month', {col}) AT TIME ZONE 'UTC'",
+ 'P0.25Y': "DATE_TRUNC('quarter', {col}) AT TIME ZONE 'UTC'",
+ 'P1Y': "DATE_TRUNC('year', {col}) AT TIME ZONE 'UTC'",
+ }
Review comment:
Nice! This is much cleaner now. Love it!
----------------------------------------------------------------
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]