mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: Time shifts with different granularity for ECharts (#24176)
This commit is contained in:
committed by
GitHub
parent
e922f0993d
commit
e5b7f7c9b5
@@ -23,6 +23,7 @@ from flask_babel import gettext as __
|
||||
from sqlalchemy import types
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
|
||||
from superset.constants import TimeGrain
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.errors import SupersetErrorType
|
||||
|
||||
@@ -40,23 +41,24 @@ class SqliteEngineSpec(BaseEngineSpec):
|
||||
|
||||
_time_grain_expressions = {
|
||||
None: "{col}",
|
||||
"PT1S": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:%S', {col}))",
|
||||
"PT1M": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:00', {col}))",
|
||||
"PT1H": "DATETIME(STRFTIME('%Y-%m-%dT%H:00:00', {col}))",
|
||||
"P1D": "DATETIME({col}, 'start of day')",
|
||||
"P1W": "DATETIME({col}, 'start of day', -strftime('%w', {col}) || ' days')",
|
||||
"P1M": "DATETIME({col}, 'start of month')",
|
||||
"P3M": (
|
||||
TimeGrain.SECOND: "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:%S', {col}))",
|
||||
TimeGrain.MINUTE: "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:00', {col}))",
|
||||
TimeGrain.HOUR: "DATETIME(STRFTIME('%Y-%m-%dT%H:00:00', {col}))",
|
||||
TimeGrain.DAY: "DATETIME({col}, 'start of day')",
|
||||
TimeGrain.WEEK: "DATETIME({col}, 'start of day', \
|
||||
-strftime('%w', {col}) || ' days')",
|
||||
TimeGrain.MONTH: "DATETIME({col}, 'start of month')",
|
||||
TimeGrain.QUARTER: (
|
||||
"DATETIME({col}, 'start of month', "
|
||||
"printf('-%d month', (strftime('%m', {col}) - 1) % 3))"
|
||||
),
|
||||
"P1Y": "DATETIME({col}, 'start of year')",
|
||||
"P1W/1970-01-03T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 6')",
|
||||
"P1W/1970-01-04T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 0')",
|
||||
"1969-12-28T00:00:00Z/P1W": (
|
||||
TimeGrain.YEAR: "DATETIME({col}, 'start of year')",
|
||||
TimeGrain.WEEK_ENDING_SATURDAY: "DATETIME({col}, 'start of day', 'weekday 6')",
|
||||
TimeGrain.WEEK_ENDING_SUNDAY: "DATETIME({col}, 'start of day', 'weekday 0')",
|
||||
TimeGrain.WEEK_STARTING_SUNDAY: (
|
||||
"DATETIME({col}, 'start of day', 'weekday 0', '-7 days')"
|
||||
),
|
||||
"1969-12-29T00:00:00Z/P1W": (
|
||||
TimeGrain.WEEK_STARTING_MONDAY: (
|
||||
"DATETIME({col}, 'start of day', 'weekday 1', '-7 days')"
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user