From c61ac76d40bc56203ea75e568cfcf5670080aea0 Mon Sep 17 00:00:00 2001 From: Fabian Stanke <825364+fmos@users.noreply.github.com> Date: Wed, 21 Sep 2022 14:02:59 +0200 Subject: [PATCH] Fix the timezone format for Apache Arrow (pyarrow) This is an update of my previous patch 0b49ca6 to make the format returned by Postgres' DATE_TRUNC compatible with pyarrow (used for calling prophet). --- superset/db_engine_specs/postgres.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py index f9d450a3e9c9e..0d7eb8ee36f07 100644 --- a/superset/db_engine_specs/postgres.py +++ b/superset/db_engine_specs/postgres.py @@ -83,14 +83,14 @@ class PostgresBaseEngineSpec(BaseEngineSpec): _time_grain_expressions = { None: "{col}", - "PT1S": "DATE_TRUNC('second', {col})", - "PT1M": "DATE_TRUNC('minute', {col})", - "PT1H": "DATE_TRUNC('hour', {col})", - "P1D": "DATE_TRUNC('day', {col})", - "P1W": "DATE_TRUNC('week', {col})", - "P1M": "DATE_TRUNC('month', {col})", - "P3M": "DATE_TRUNC('quarter', {col})", - "P1Y": "DATE_TRUNC('year', {col})", + "PT1S": "DATE_TRUNC('second', {col})::timestamp", + "PT1M": "DATE_TRUNC('minute', {col})::timestamp", + "PT1H": "DATE_TRUNC('hour', {col})::timestamp", + "P1D": "DATE_TRUNC('day', {col})::timestamp", + "P1W": "DATE_TRUNC('week', {col})::timestamp", + "P1M": "DATE_TRUNC('month', {col})::timestamp", + "P3M": "DATE_TRUNC('quarter', {col})::timestamp", + "P1Y": "DATE_TRUNC('year', {col})::timestamp", } custom_errors: Dict[Pattern[str], Tuple[str, SupersetErrorType, Dict[str, Any]]] = {