Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
fix(presto,trino): use correct literal dttm separator (apache#20123)
Browse files Browse the repository at this point in the history
* fix(presto,trino): use correct literal dttm separator

* remove redundant tests
  • Loading branch information
villebro committed May 19, 2022
1 parent d5c5e58 commit e2f11d3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 34 deletions.
2 changes: 1 addition & 1 deletion superset/db_engine_specs/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions tests/integration_tests/db_engine_specs/presto_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
13 changes: 0 additions & 13 deletions tests/integration_tests/db_engine_specs/trino_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/db_engine_specs/test_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
),
],
)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/db_engine_specs/test_trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
),
],
)
Expand Down

0 comments on commit e2f11d3

Please sign in to comment.