mirror of
https://github.com/apache/superset.git
synced 2026-04-24 02:25:13 +00:00
fix: Time shifts with different granularity for ECharts (#24176)
This commit is contained in:
committed by
GitHub
parent
e922f0993d
commit
e5b7f7c9b5
@@ -22,6 +22,7 @@ from typing import Any, Optional
|
||||
from flask_babel import gettext as __
|
||||
from sqlalchemy import types
|
||||
|
||||
from superset.constants import TimeGrain
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.errors import SupersetErrorType
|
||||
|
||||
@@ -38,17 +39,17 @@ class AthenaEngineSpec(BaseEngineSpec):
|
||||
|
||||
_time_grain_expressions = {
|
||||
None: "{col}",
|
||||
"PT1S": "date_trunc('second', CAST({col} AS TIMESTAMP))",
|
||||
"PT1M": "date_trunc('minute', CAST({col} AS TIMESTAMP))",
|
||||
"PT1H": "date_trunc('hour', CAST({col} AS TIMESTAMP))",
|
||||
"P1D": "date_trunc('day', CAST({col} AS TIMESTAMP))",
|
||||
"P1W": "date_trunc('week', CAST({col} AS TIMESTAMP))",
|
||||
"P1M": "date_trunc('month', 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', \
|
||||
TimeGrain.SECOND: "date_trunc('second', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.MINUTE: "date_trunc('minute', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.HOUR: "date_trunc('hour', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.DAY: "date_trunc('day', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.WEEK: "date_trunc('week', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.MONTH: "date_trunc('month', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.QUARTER: "date_trunc('quarter', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.YEAR: "date_trunc('year', CAST({col} AS TIMESTAMP))",
|
||||
TimeGrain.WEEK_ENDING_SATURDAY: "date_add('day', 5, date_trunc('week', \
|
||||
date_add('day', 1, CAST({col} AS TIMESTAMP))))",
|
||||
"1969-12-28T00:00:00Z/P1W": "date_add('day', -1, date_trunc('week', \
|
||||
TimeGrain.WEEK_STARTING_SUNDAY: "date_add('day', -1, date_trunc('week', \
|
||||
date_add('day', 1, CAST({col} AS TIMESTAMP))))",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user