You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/04/05 22:58:24 UTC

[superset] 01/01: feat(presto) `get_catalog_names`

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

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

commit 739445fc3e902624d9b8b2884557b5f8da161d36
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Apr 5 15:58:02 2023 -0700

    feat(presto) `get_catalog_names`
---
 superset/db_engine_specs/postgres.py |  2 +-
 superset/db_engine_specs/presto.py   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py
index e52e69d7e8..352c9f466b 100644
--- a/superset/db_engine_specs/postgres.py
+++ b/superset/db_engine_specs/postgres.py
@@ -310,7 +310,7 @@ class PostgresEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
 SELECT datname FROM pg_database
 WHERE datistemplate = false;
             """
-            ).fetchall()
+            )
         )
 
     @classmethod
diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py
index c0b4f2c6dd..a9b4f7aa60 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -785,6 +785,17 @@ class PrestoEngineSpec(PrestoBaseEngineSpec):
             results = cursor.fetchall()
             return {row[0] for row in results}
 
+    @classmethod
+    def get_catalog_names(
+        cls,
+        database: Database,
+        inspector: Inspector,
+    ) -> List[str]:
+        """
+        Get all catalogs.
+        """
+        return [catalog for (catalog,) in inspector.bind.execute("SHOW CATALOGS")]
+
     @classmethod
     def _create_column_info(
         cls, name: str, data_type: types.TypeEngine