mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat(bigquery): implement custom minute time grains (#12581)
* feat(bigquery): implement custom minute time grains * address review comment
This commit is contained in:
@@ -74,6 +74,28 @@ class TestBigQueryDbEngineSpec(TestDbEngineSpec):
|
||||
)
|
||||
self.assertEqual(str(actual), expected)
|
||||
|
||||
def test_custom_minute_timegrain_expressions(self):
|
||||
"""
|
||||
DB Eng Specs (bigquery): Test time grain expressions
|
||||
"""
|
||||
col = column("temporal")
|
||||
test_cases = {
|
||||
"DATE": "CAST(TIMESTAMP_SECONDS("
|
||||
"5*60 * DIV(UNIX_SECONDS(CAST(temporal AS TIMESTAMP)), 5*60)"
|
||||
") AS DATE)",
|
||||
"DATETIME": "CAST(TIMESTAMP_SECONDS("
|
||||
"5*60 * DIV(UNIX_SECONDS(CAST(temporal AS TIMESTAMP)), 5*60)"
|
||||
") AS DATETIME)",
|
||||
"TIMESTAMP": "CAST(TIMESTAMP_SECONDS("
|
||||
"5*60 * DIV(UNIX_SECONDS(CAST(temporal AS TIMESTAMP)), 5*60)"
|
||||
") AS TIMESTAMP)",
|
||||
}
|
||||
for type_, expected in test_cases.items():
|
||||
actual = BigQueryEngineSpec.get_timestamp_expr(
|
||||
col=col, pdf=None, time_grain="PT5M", type_=type_
|
||||
)
|
||||
assert str(actual) == expected
|
||||
|
||||
def test_fetch_data(self):
|
||||
"""
|
||||
DB Eng Specs (bigquery): Test fetch data
|
||||
|
||||
Reference in New Issue
Block a user