This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 8c0ac9017f fix: Presto _show_columns return type (#20757)
8c0ac9017f is described below

commit 8c0ac9017f414c36c1b8110a48a242bca3688969
Author: John Bodley <[email protected]>
AuthorDate: Tue Jul 19 09:52:22 2022 -0700

    fix: Presto _show_columns return type (#20757)
---
 superset/db_engine_specs/presto.py                     |  3 +--
 .../integration_tests/db_engine_specs/presto_tests.py  | 18 +++++++++++-------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/superset/db_engine_specs/presto.py 
b/superset/db_engine_specs/presto.py
index 74b10e3584..b310e37429 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -442,8 +442,7 @@ class PrestoEngineSpec(BaseEngineSpec):  # pylint: 
disable=too-many-public-metho
         full_table = quote(table_name)
         if schema:
             full_table = "{}.{}".format(quote(schema), full_table)
-        columns = inspector.bind.execute("SHOW COLUMNS FROM 
{}".format(full_table))
-        return columns
+        return inspector.bind.execute(f"SHOW COLUMNS FROM 
{full_table}").fetchall()
 
     column_type_mappings = (
         (
diff --git a/tests/integration_tests/db_engine_specs/presto_tests.py 
b/tests/integration_tests/db_engine_specs/presto_tests.py
index 90065de892..a991a4d22c 100644
--- a/tests/integration_tests/db_engine_specs/presto_tests.py
+++ b/tests/integration_tests/db_engine_specs/presto_tests.py
@@ -84,7 +84,7 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
         inspector.engine.dialect.identifier_preparer.quote_identifier = 
mock.Mock()
         row = mock.Mock()
         row.Column, row.Type, row.Null = column
-        inspector.bind.execute = mock.Mock(return_value=[row])
+        inspector.bind.execute.return_value.fetchall = 
mock.Mock(return_value=[row])
         results = PrestoEngineSpec.get_columns(inspector, "", "")
         self.assertEqual(len(expected_results), len(results))
         for expected_result, result in zip(expected_results, results):
@@ -744,25 +744,29 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
         inspector.engine.dialect.identifier_preparer.quote_identifier = (
             lambda x: f'"{x}"'
         )
-        mock_execute = mock.MagicMock(return_value=["a", "b"])
-        inspector.bind.execute = mock_execute
+        inspector.bind.execute.return_value.fetchall = mock.MagicMock(
+            return_value=["a", "b"]
+        )
         table_name = "table_name"
         result = PrestoEngineSpec._show_columns(inspector, table_name, None)
         assert result == ["a", "b"]
-        mock_execute.assert_called_once_with(f'SHOW COLUMNS FROM 
"{table_name}"')
+        inspector.bind.execute.assert_called_once_with(
+            f'SHOW COLUMNS FROM "{table_name}"'
+        )
 
     def test_show_columns_with_schema(self):
         inspector = mock.MagicMock()
         inspector.engine.dialect.identifier_preparer.quote_identifier = (
             lambda x: f'"{x}"'
         )
-        mock_execute = mock.MagicMock(return_value=["a", "b"])
-        inspector.bind.execute = mock_execute
+        inspector.bind.execute.return_value.fetchall = mock.MagicMock(
+            return_value=["a", "b"]
+        )
         table_name = "table_name"
         schema = "schema"
         result = PrestoEngineSpec._show_columns(inspector, table_name, schema)
         assert result == ["a", "b"]
-        mock_execute.assert_called_once_with(
+        inspector.bind.execute.assert_called_once_with(
             f'SHOW COLUMNS FROM "{schema}"."{table_name}"'
         )
 

Reply via email to