You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2022/06/23 17:52:43 UTC
[superset] 20/27: fix(viz): BigQuery time grain 'minute'/'second' throws an error (#20350)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit f26142861366ca3f599e104e3aacc05922fa0421
Author: Diego Medina <di...@gmail.com>
AuthorDate: Tue Jun 21 10:06:52 2022 -0300
fix(viz): BigQuery time grain 'minute'/'second' throws an error (#20350)
(cherry picked from commit 5afeba34bd72526844d0f71764309a6669d96c5a)
---
superset/db_engine_specs/bigquery.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/superset/db_engine_specs/bigquery.py b/superset/db_engine_specs/bigquery.py
index e33457c79a..51fd710ab3 100644
--- a/superset/db_engine_specs/bigquery.py
+++ b/superset/db_engine_specs/bigquery.py
@@ -123,8 +123,12 @@ class BigQueryEngineSpec(BaseEngineSpec):
_time_grain_expressions = {
None: "{col}",
- "PT1S": "{func}({col}, SECOND)",
- "PT1M": "{func}({col}, MINUTE)",
+ "PT1S": "CAST(TIMESTAMP_SECONDS("
+ "UNIX_SECONDS(CAST({col} AS TIMESTAMP))"
+ ") AS {type})",
+ "PT1M": "CAST(TIMESTAMP_SECONDS("
+ "60 * DIV(UNIX_SECONDS(CAST({col} AS TIMESTAMP)), 60)"
+ ") AS {type})",
"PT5M": "CAST(TIMESTAMP_SECONDS("
"5*60 * DIV(UNIX_SECONDS(CAST({col} AS TIMESTAMP)), 5*60)"
") AS {type})",