diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py index 8fa4d2794a31..9a72b7608165 100644 --- a/superset/db_engine_specs/presto.py +++ b/superset/db_engine_specs/presto.py @@ -761,7 +761,7 @@ def convert_dttm( utils.TemporalType.TIMESTAMP, utils.TemporalType.TIMESTAMP_WITH_TIME_ZONE, ): - return f"""TIMESTAMP '{dttm.isoformat(timespec="microseconds")}'""" + return f"""TIMESTAMP '{dttm.isoformat(timespec="microseconds", sep=" ")}'""" return None @classmethod diff --git a/superset/db_engine_specs/trino.py b/superset/db_engine_specs/trino.py index f9d06bb9c6a7..9941c57d985b 100644 --- a/superset/db_engine_specs/trino.py +++ b/superset/db_engine_specs/trino.py @@ -76,7 +76,7 @@ def convert_dttm( utils.TemporalType.TIMESTAMP, utils.TemporalType.TIMESTAMP_WITH_TIME_ZONE, ): - return f"""TIMESTAMP '{dttm.isoformat(timespec="microseconds")}'""" + return f"""TIMESTAMP '{dttm.isoformat(timespec="microseconds", sep=" ")}'""" return None @classmethod diff --git a/tests/integration_tests/db_engine_specs/presto_tests.py b/tests/integration_tests/db_engine_specs/presto_tests.py index acb9922d4563..954f8d660a97 100644 --- a/tests/integration_tests/db_engine_specs/presto_tests.py +++ b/tests/integration_tests/db_engine_specs/presto_tests.py @@ -512,19 +512,6 @@ def test_presto_where_latest_partition(self): query_result = str(result.compile(compile_kwargs={"literal_binds": True})) self.assertEqual("SELECT \nWHERE ds = '01-01-19' AND hour = 1", query_result) - def test_convert_dttm(self): - dttm = self.get_dttm() - - self.assertEqual( - PrestoEngineSpec.convert_dttm("DATE", dttm), - "DATE '2019-01-02'", - ) - - self.assertEqual( - PrestoEngineSpec.convert_dttm("TIMESTAMP", dttm), - "TIMESTAMP '2019-01-02T03:04:05.678900'", - ) - def test_query_cost_formatter(self): raw_cost = [ { diff --git a/tests/integration_tests/db_engine_specs/trino_tests.py b/tests/integration_tests/db_engine_specs/trino_tests.py index 18f00b8988c4..b2235ae0c726 100644 --- a/tests/integration_tests/db_engine_specs/trino_tests.py +++ b/tests/integration_tests/db_engine_specs/trino_tests.py @@ -27,19 +27,6 @@ class TestTrinoDbEngineSpec(TestDbEngineSpec): - def test_convert_dttm(self): - dttm = self.get_dttm() - - self.assertEqual( - TrinoEngineSpec.convert_dttm("DATE", dttm), - "DATE '2019-01-02'", - ) - - self.assertEqual( - TrinoEngineSpec.convert_dttm("TIMESTAMP", dttm), - "TIMESTAMP '2019-01-02T03:04:05.678900'", - ) - def test_adjust_database_uri(self): url = URL(drivername="trino", database="hive") TrinoEngineSpec.adjust_database_uri(url, selected_schema="foobar") diff --git a/tests/unit_tests/db_engine_specs/test_presto.py b/tests/unit_tests/db_engine_specs/test_presto.py index 5bb327ff4ebc..512d03096b0b 100644 --- a/tests/unit_tests/db_engine_specs/test_presto.py +++ b/tests/unit_tests/db_engine_specs/test_presto.py @@ -30,17 +30,17 @@ ( "TIMESTAMP", datetime(2022, 1, 1, 1, 23, 45, 600000), - "TIMESTAMP '2022-01-01T01:23:45.600000'", + "TIMESTAMP '2022-01-01 01:23:45.600000'", ), ( "TIMESTAMP WITH TIME ZONE", datetime(2022, 1, 1, 1, 23, 45, 600000), - "TIMESTAMP '2022-01-01T01:23:45.600000'", + "TIMESTAMP '2022-01-01 01:23:45.600000'", ), ( "TIMESTAMP WITH TIME ZONE", datetime(2022, 1, 1, 1, 23, 45, 600000, tzinfo=pytz.UTC), - "TIMESTAMP '2022-01-01T01:23:45.600000+00:00'", + "TIMESTAMP '2022-01-01 01:23:45.600000+00:00'", ), ], ) diff --git a/tests/unit_tests/db_engine_specs/test_trino.py b/tests/unit_tests/db_engine_specs/test_trino.py index 1e800f3ad6db..692fe875da0e 100644 --- a/tests/unit_tests/db_engine_specs/test_trino.py +++ b/tests/unit_tests/db_engine_specs/test_trino.py @@ -30,17 +30,17 @@ ( "TIMESTAMP", datetime(2022, 1, 1, 1, 23, 45, 600000), - "TIMESTAMP '2022-01-01T01:23:45.600000'", + "TIMESTAMP '2022-01-01 01:23:45.600000'", ), ( "TIMESTAMP WITH TIME ZONE", datetime(2022, 1, 1, 1, 23, 45, 600000), - "TIMESTAMP '2022-01-01T01:23:45.600000'", + "TIMESTAMP '2022-01-01 01:23:45.600000'", ), ( "TIMESTAMP WITH TIME ZONE", datetime(2022, 1, 1, 1, 23, 45, 600000, tzinfo=pytz.UTC), - "TIMESTAMP '2022-01-01T01:23:45.600000+00:00'", + "TIMESTAMP '2022-01-01 01:23:45.600000+00:00'", ), ], )