Skip to content

Commit

Permalink
chore(engine): Translate fractional time grains—requires @superset-ui…
Browse files Browse the repository at this point in the history
… bump (#17078)

* chore(engine): Translate fractional time grains

* Bump @superset-ui

Co-authored-by: John Bodley <john.bodley@airbnb.com>
  • Loading branch information
john-bodley and John Bodley authored Oct 13, 2021
1 parent 959fd76 commit b9ff85d
Show file tree
Hide file tree
Showing 37 changed files with 453 additions and 381 deletions.
8 changes: 4 additions & 4 deletions docs/src/resources/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,13 @@
"PT5M",
"PT10M",
"PT15M",
"PT0.5H",
"PT30M",
"PT1H",
"PT6H",
"P1D",
"P1W",
"P1M",
"P0.25Y",
"P3M",
"P1Y",
"1969-12-28T00:00:00Z/P1W",
"1969-12-29T00:00:00Z/P1W",
Expand Down Expand Up @@ -998,13 +998,13 @@
"PT5M",
"PT10M",
"PT15M",
"PT0.5H",
"PT30M",
"PT1H",
"PT6H",
"P1D",
"P1W",
"P1M",
"P0.25Y",
"P3M",
"P1Y",
"1969-12-28T00:00:00Z/P1W",
"1969-12-29T00:00:00Z/P1W",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Visualization > Table', () => {
...VIZ_DEFAULTS,
include_time: true,
granularity_sqla: 'ds',
time_grain_sqla: 'P0.25Y',
time_grain_sqla: 'P3M',
metrics: [NUM_METRIC, MAX_DS, MAX_STATE],
});
// when format with smart_date, time column use format by granularity
Expand All @@ -77,7 +77,7 @@ describe('Visualization > Table', () => {
...VIZ_DEFAULTS,
include_time: true,
granularity_sqla: 'ds',
time_grain_sqla: 'P0.25Y',
time_grain_sqla: 'P3M',
table_timestamp_format: '%Y-%m-%d %H:%M',
metrics: [NUM_METRIC, MAX_DS, MAX_STATE],
});
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Visualization > Table', () => {
...VIZ_DEFAULTS,
include_time: true,
granularity_sqla: 'ds',
time_grain_sqla: 'P0.25Y',
time_grain_sqla: 'P3M',
metrics: [NUM_METRIC, MAX_DS],
groupby: ['name'],
});
Expand Down
604 changes: 302 additions & 302 deletions superset-frontend/package-lock.json

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,35 @@
"@emotion/cache": "^11.4.0",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@superset-ui/chart-controls": "^0.18.10",
"@superset-ui/core": "^0.18.10",
"@superset-ui/legacy-plugin-chart-calendar": "^0.18.10",
"@superset-ui/legacy-plugin-chart-chord": "^0.18.10",
"@superset-ui/legacy-plugin-chart-country-map": "^0.18.10",
"@superset-ui/legacy-plugin-chart-event-flow": "^0.18.10",
"@superset-ui/legacy-plugin-chart-force-directed": "^0.18.10",
"@superset-ui/legacy-plugin-chart-heatmap": "^0.18.10",
"@superset-ui/legacy-plugin-chart-histogram": "^0.18.10",
"@superset-ui/legacy-plugin-chart-horizon": "^0.18.10",
"@superset-ui/legacy-plugin-chart-map-box": "^0.18.10",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.18.10",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.18.10",
"@superset-ui/legacy-plugin-chart-partition": "^0.18.10",
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.18.10",
"@superset-ui/legacy-plugin-chart-rose": "^0.18.10",
"@superset-ui/legacy-plugin-chart-sankey": "^0.18.10",
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.18.10",
"@superset-ui/legacy-plugin-chart-sunburst": "^0.18.10",
"@superset-ui/legacy-plugin-chart-treemap": "^0.18.10",
"@superset-ui/legacy-plugin-chart-world-map": "^0.18.10",
"@superset-ui/legacy-preset-chart-big-number": "^0.18.10",
"@superset-ui/chart-controls": "^0.18.12",
"@superset-ui/core": "^0.18.12",
"@superset-ui/legacy-plugin-chart-calendar": "^0.18.12",
"@superset-ui/legacy-plugin-chart-chord": "^0.18.12",
"@superset-ui/legacy-plugin-chart-country-map": "^0.18.12",
"@superset-ui/legacy-plugin-chart-event-flow": "^0.18.12",
"@superset-ui/legacy-plugin-chart-force-directed": "^0.18.12",
"@superset-ui/legacy-plugin-chart-heatmap": "^0.18.12",
"@superset-ui/legacy-plugin-chart-histogram": "^0.18.12",
"@superset-ui/legacy-plugin-chart-horizon": "^0.18.12",
"@superset-ui/legacy-plugin-chart-map-box": "^0.18.12",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.18.12",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.18.12",
"@superset-ui/legacy-plugin-chart-partition": "^0.18.12",
"@superset-ui/legacy-plugin-chart-pivot-table": "^0.18.12",
"@superset-ui/legacy-plugin-chart-rose": "^0.18.12",
"@superset-ui/legacy-plugin-chart-sankey": "^0.18.12",
"@superset-ui/legacy-plugin-chart-sankey-loop": "^0.18.12",
"@superset-ui/legacy-plugin-chart-sunburst": "^0.18.12",
"@superset-ui/legacy-plugin-chart-treemap": "^0.18.12",
"@superset-ui/legacy-plugin-chart-world-map": "^0.18.12",
"@superset-ui/legacy-preset-chart-big-number": "^0.18.12",
"@superset-ui/legacy-preset-chart-deckgl": "^0.4.12",
"@superset-ui/legacy-preset-chart-nvd3": "^0.18.10",
"@superset-ui/plugin-chart-echarts": "^0.18.10",
"@superset-ui/plugin-chart-pivot-table": "^0.18.10",
"@superset-ui/plugin-chart-table": "^0.18.10",
"@superset-ui/plugin-chart-word-cloud": "^0.18.10",
"@superset-ui/preset-chart-xy": "^0.18.10",
"@superset-ui/legacy-preset-chart-nvd3": "^0.18.12",
"@superset-ui/plugin-chart-echarts": "^0.18.12",
"@superset-ui/plugin-chart-pivot-table": "^0.18.12",
"@superset-ui/plugin-chart-table": "^0.18.12",
"@superset-ui/plugin-chart-word-cloud": "^0.18.12",
"@superset-ui/preset-chart-xy": "^0.18.12",
"@vx/responsive": "^0.0.195",
"abortcontroller-polyfill": "^1.1.9",
"antd": "^4.9.4",
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/ascend.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ class AscendEngineSpec(ImpalaEngineSpec):
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}
2 changes: 1 addition & 1 deletion superset/db_engine_specs/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AthenaEngineSpec(BaseEngineSpec):
"P1D": "date_trunc('day', CAST({col} AS TIMESTAMP))",
"P1W": "date_trunc('week', CAST({col} AS TIMESTAMP))",
"P1M": "date_trunc('month', CAST({col} AS TIMESTAMP))",
"P0.25Y": "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
"P3M": "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
"P1Y": "date_trunc('year', CAST({col} AS TIMESTAMP))",
"P1W/1970-01-03T00:00:00Z": "date_add('day', 5, date_trunc('week', \
date_add('day', 1, CAST({col} AS TIMESTAMP))))",
Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ class TimeGrain(NamedTuple):
"PT5M": __("5 minute"),
"PT10M": __("10 minute"),
"PT15M": __("15 minute"),
"PT0.5H": __("Half hour"),
"PT30M": __("30 minute"),
"PT1H": __("Hour"),
"PT6H": __("6 hour"),
"P1D": __("Day"),
"P1W": __("Week"),
"P1M": __("Month"),
"P0.25Y": __("Quarter"),
"P3M": __("Quarter"),
"P1Y": __("Year"),
"1969-12-28T00:00:00Z/P1W": __("Week starting Sunday"),
"1969-12-29T00:00:00Z/P1W": __("Week starting Monday"),
Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ class BigQueryEngineSpec(BaseEngineSpec):
"PT15M": "CAST(TIMESTAMP_SECONDS("
"15*60 * DIV(UNIX_SECONDS(CAST({col} AS TIMESTAMP)), 15*60)"
") AS {type})",
"PT0.5H": "CAST(TIMESTAMP_SECONDS("
"PT30M": "CAST(TIMESTAMP_SECONDS("
"30*60 * DIV(UNIX_SECONDS(CAST({col} AS TIMESTAMP)), 30*60)"
") AS {type})",
"PT1H": "{func}({col}, HOUR)",
"P1D": "{func}({col}, DAY)",
"P1W": "{func}({col}, WEEK)",
"P1M": "{func}({col}, MONTH)",
"P0.25Y": "{func}({col}, QUARTER)",
"P3M": "{func}({col}, QUARTER)",
"P1Y": "{func}({col}, YEAR)",
}

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class ClickHouseEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
"PT5M": "toDateTime(intDiv(toUInt32(toDateTime({col})), 300)*300)",
"PT10M": "toDateTime(intDiv(toUInt32(toDateTime({col})), 600)*600)",
"PT15M": "toDateTime(intDiv(toUInt32(toDateTime({col})), 900)*900)",
"PT0.5H": "toDateTime(intDiv(toUInt32(toDateTime({col})), 1800)*1800)",
"PT30M": "toDateTime(intDiv(toUInt32(toDateTime({col})), 1800)*1800)",
"PT1H": "toStartOfHour(toDateTime({col}))",
"P1D": "toStartOfDay(toDateTime({col}))",
"P1W": "toMonday(toDateTime({col}))",
"P1M": "toStartOfMonth(toDateTime({col}))",
"P0.25Y": "toStartOfQuarter(toDateTime({col}))",
"P3M": "toStartOfQuarter(toDateTime({col}))",
"P1Y": "toStartOfYear(toDateTime({col}))",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/crate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CrateEngineSpec(BaseEngineSpec):
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/db2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Db2EngineSpec(BaseEngineSpec):
" - MICROSECOND({col}) MICROSECONDS",
"P1W": "{col} - (DAYOFWEEK({col})) DAYS",
"P1M": "{col} - (DAY({col})-1) DAYS",
"P0.25Y": "{col} - (DAY({col})-1) DAYS"
"P3M": "{col} - (DAY({col})-1) DAYS"
" - (MONTH({col})-1) MONTHS"
" + ((QUARTER({col})-1) * 3) MONTHS",
"P1Y": "{col} - (DAY({col})-1) DAYS" " - (MONTH({col})-1) MONTHS",
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/dremio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DremioEngineSpec(BaseEngineSpec):
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/drill.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class DrillEngineSpec(BaseEngineSpec):
"PT1S": "NEARESTDATE({col}, 'SECOND')",
"PT1M": "NEARESTDATE({col}, 'MINUTE')",
"PT15M": "NEARESTDATE({col}, 'QUARTER_HOUR')",
"PT0.5H": "NEARESTDATE({col}, 'HALF_HOUR')",
"PT30M": "NEARESTDATE({col}, 'HALF_HOUR')",
"PT1H": "NEARESTDATE({col}, 'HOUR')",
"P1D": "NEARESTDATE({col}, 'DAY')",
"P1W": "NEARESTDATE({col}, 'WEEK_SUNDAY')",
"P1M": "NEARESTDATE({col}, 'MONTH')",
"P0.25Y": "NEARESTDATE({col}, 'QUARTER')",
"P3M": "NEARESTDATE({col}, 'QUARTER')",
"P1Y": "NEARESTDATE({col}, 'YEAR')",
}

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class DruidEngineSpec(BaseEngineSpec):
"PT5M": "TIME_FLOOR({col}, 'PT5M')",
"PT10M": "TIME_FLOOR({col}, 'PT10M')",
"PT15M": "TIME_FLOOR({col}, 'PT15M')",
"PT0.5H": "TIME_FLOOR({col}, 'PT30M')",
"PT30M": "TIME_FLOOR({col}, 'PT30M')",
"PT1H": "TIME_FLOOR({col}, 'PT1H')",
"PT6H": "TIME_FLOOR({col}, 'PT6H')",
"P1D": "TIME_FLOOR({col}, 'P1D')",
"P1W": "TIME_FLOOR({col}, 'P1W')",
"P1M": "TIME_FLOOR({col}, 'P1M')",
"P0.25Y": "TIME_FLOOR({col}, 'P3M')",
"P3M": "TIME_FLOOR({col}, 'P3M')",
"P1Y": "TIME_FLOOR({col}, 'P1Y')",
"P1W/1970-01-03T00:00:00Z": (
"TIME_SHIFT(TIME_FLOOR(TIME_SHIFT({col}, 'P1D', 1), 'P1W'), 'P1D', 5)"
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ExasolEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/firebolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FireboltEngineSpec(BaseEngineSpec):
"P1D": "date_trunc('day', CAST({col} AS TIMESTAMP))",
"P1W": "date_trunc('week', CAST({col} AS TIMESTAMP))",
"P1M": "date_trunc('month', CAST({col} AS TIMESTAMP))",
"P0.25Y": "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
"P3M": "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
"P1Y": "date_trunc('year', CAST({col} AS TIMESTAMP))",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/hana.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HanaEngineSpec(PostgresBaseEngineSpec):
"PT1H": "TO_TIMESTAMP(SUBSTRING(TO_TIMESTAMP({col}),0,14) || '00:00')",
"P1D": "TO_DATE({col})",
"P1M": "TO_DATE(SUBSTRING(TO_DATE({col}),0,7)||'-01')",
"P0.25Y": "TO_DATE(SUBSTRING( \
"P3M": "TO_DATE(SUBSTRING( \
TO_DATE({col}), 0, 5)|| LPAD(CAST((CAST(SUBSTRING(QUARTER( \
TO_DATE({col}), 1), 7, 1) as int)-1)*3 +1 as text),2,'0') ||'-01')",
"P1Y": "TO_DATE(YEAR({col})||'-01-01')",
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class HiveEngineSpec(PrestoEngineSpec):
"P1D": "from_unixtime(unix_timestamp({col}), 'yyyy-MM-dd 00:00:00')",
"P1W": "date_format(date_sub({col}, CAST(7-from_unixtime(unix_timestamp({col}),'u') as int)), 'yyyy-MM-dd 00:00:00')",
"P1M": "from_unixtime(unix_timestamp({col}), 'yyyy-MM-01 00:00:00')",
"P0.25Y": "date_format(add_months(trunc({col}, 'MM'), -(month({col})-1)%3), 'yyyy-MM-dd 00:00:00')",
"P3M": "date_format(add_months(trunc({col}, 'MM'), -(month({col})-1)%3), 'yyyy-MM-dd 00:00:00')",
"P1Y": "from_unixtime(unix_timestamp({col}), 'yyyy-01-01 00:00:00')",
"P1W/1970-01-03T00:00:00Z": "date_format(date_add({col}, INT(6-from_unixtime(unix_timestamp({col}), 'u'))), 'yyyy-MM-dd 00:00:00')",
"1969-12-28T00:00:00Z/P1W": "date_format(date_add({col}, -INT(from_unixtime(unix_timestamp({col}), 'u'))), 'yyyy-MM-dd 00:00:00')",
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/impala.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ImpalaEngineSpec(BaseEngineSpec):
"P1D": "TRUNC({col}, 'DD')",
"P1W": "TRUNC({col}, 'WW')",
"P1M": "TRUNC({col}, 'MONTH')",
"P0.25Y": "TRUNC({col}, 'Q')",
"P3M": "TRUNC({col}, 'Q')",
"P1Y": "TRUNC({col}, 'YYYY')",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/kylin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class KylinEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
"P1D": "CAST(FLOOR(CAST({col} AS TIMESTAMP) TO DAY) AS DATE)",
"P1W": "CAST(FLOOR(CAST({col} AS TIMESTAMP) TO WEEK) AS DATE)",
"P1M": "CAST(FLOOR(CAST({col} AS TIMESTAMP) TO MONTH) AS DATE)",
"P0.25Y": "CAST(FLOOR(CAST({col} AS TIMESTAMP) TO QUARTER) AS DATE)",
"P3M": "CAST(FLOOR(CAST({col} AS TIMESTAMP) TO QUARTER) AS DATE)",
"P1Y": "CAST(FLOOR(CAST({col} AS TIMESTAMP) TO YEAR) AS DATE)",
}

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class MssqlEngineSpec(BaseEngineSpec):
"PT5M": "DATEADD(minute, DATEDIFF(minute, 0, {col}) / 5 * 5, 0)",
"PT10M": "DATEADD(minute, DATEDIFF(minute, 0, {col}) / 10 * 10, 0)",
"PT15M": "DATEADD(minute, DATEDIFF(minute, 0, {col}) / 15 * 15, 0)",
"PT0.5H": "DATEADD(minute, DATEDIFF(minute, 0, {col}) / 30 * 30, 0)",
"PT30M": "DATEADD(minute, DATEDIFF(minute, 0, {col}) / 30 * 30, 0)",
"PT1H": "DATEADD(hour, DATEDIFF(hour, 0, {col}), 0)",
"P1D": "DATEADD(day, DATEDIFF(day, 0, {col}), 0)",
"P1W": "DATEADD(week, DATEDIFF(week, 0, {col}), 0)",
"P1M": "DATEADD(month, DATEDIFF(month, 0, {col}), 0)",
"P0.25Y": "DATEADD(quarter, DATEDIFF(quarter, 0, {col}), 0)",
"P3M": "DATEADD(quarter, DATEDIFF(quarter, 0, {col}), 0)",
"P1Y": "DATEADD(year, DATEDIFF(year, 0, {col}), 0)",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class MySQLEngineSpec(BaseEngineSpec, BasicParametersMixin):
"P1D": "DATE({col})",
"P1W": "DATE(DATE_SUB({col}, " "INTERVAL DAYOFWEEK({col}) - 1 DAY))",
"P1M": "DATE(DATE_SUB({col}, " "INTERVAL DAYOFMONTH({col}) - 1 DAY))",
"P0.25Y": "MAKEDATE(YEAR({col}), 1) "
"P3M": "MAKEDATE(YEAR({col}), 1) "
"+ INTERVAL QUARTER({col}) QUARTER - INTERVAL 1 QUARTER",
"P1Y": "DATE(DATE_SUB({col}, " "INTERVAL DAYOFYEAR({col}) - 1 DAY))",
"1969-12-29T00:00:00Z/P1W": "DATE(DATE_SUB({col}, "
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/netezza.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NetezzaEngineSpec(PostgresBaseEngineSpec):
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OracleEngineSpec(BaseEngineSpec):
"P1D": "TRUNC(CAST({col} as DATE), 'DDD')",
"P1W": "TRUNC(CAST({col} as DATE), 'WW')",
"P1M": "TRUNC(CAST({col} as DATE), 'MONTH')",
"P0.25Y": "TRUNC(CAST({col} as DATE), 'Q')",
"P3M": "TRUNC(CAST({col} as DATE), 'Q')",
"P1Y": "TRUNC(CAST({col} as DATE), 'YEAR')",
}

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/pinot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
"P1D": "1:DAYS",
"P1W": "week",
"P1M": "month",
"P0.25Y": "quarter",
"P3MY": "quarter",
"P1Y": "year",
}

Expand All @@ -57,7 +57,7 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
"P1D": False,
"P1W": True,
"P1M": True,
"P0.25Y": True,
"P3M": True,
"P1Y": True,
}

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FixedOffsetTimezone(_FixedOffset):


class PostgresBaseEngineSpec(BaseEngineSpec):
""" Abstract class for Postgres 'like' databases """
"""Abstract class for Postgres 'like' databases"""

engine = ""
engine_name = "PostgreSQL"
Expand All @@ -103,7 +103,7 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}

Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class PrestoEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-metho
"P1D": "date_trunc('day', CAST({col} AS TIMESTAMP))",
"P1W": "date_trunc('week', CAST({col} AS TIMESTAMP))",
"P1M": "date_trunc('month', CAST({col} AS TIMESTAMP))",
"P0.25Y": "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
"P3M": "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
"P1Y": "date_trunc('year', CAST({col} AS TIMESTAMP))",
"P1W/1970-01-03T00:00:00Z": "date_add('day', 5, date_trunc('week', "
"date_add('day', 1, CAST({col} AS TIMESTAMP))))",
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/rockset.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RocksetEngineSpec(BaseEngineSpec):
"P1D": "DATE_TRUNC('day', {col})",
"P1W": "DATE_TRUNC('week', {col})",
"P1M": "DATE_TRUNC('month', {col})",
"P0.25Y": "DATE_TRUNC('quarter', {col})",
"P3M": "DATE_TRUNC('quarter', {col})",
"P1Y": "DATE_TRUNC('year', {col})",
}

Expand Down
Loading

0 comments on commit b9ff85d

Please sign in to comment.