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/06 00:07:42 UTC

[superset] branch snowflake_get_catalog_names updated (65254a4edd -> 4d703c899a)

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

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


 discard 65254a4edd feat(snowflake): add `get_catalog_names`
     new 4d703c899a feat(snowflake): add `get_catalog_names`

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (65254a4edd)
            \
             N -- N -- N   refs/heads/snowflake_get_catalog_names (4d703c899a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 superset/db_engine_specs/bigquery.py  | 2 ++
 superset/db_engine_specs/postgres.py  | 1 +
 superset/db_engine_specs/snowflake.py | 1 +
 3 files changed, 4 insertions(+)


[superset] 01/01: feat(snowflake): add `get_catalog_names`

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4d703c899a3ab9217df9f40fb2f6575a9ca3e284
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Apr 5 17:03:43 2023 -0700

    feat(snowflake): add `get_catalog_names`
---
 superset/db_engine_specs/bigquery.py  |  2 ++
 superset/db_engine_specs/postgres.py  |  1 +
 superset/db_engine_specs/snowflake.py | 20 ++++++++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/superset/db_engine_specs/bigquery.py b/superset/db_engine_specs/bigquery.py
index 4b36b24eab..f344fcac20 100644
--- a/superset/db_engine_specs/bigquery.py
+++ b/superset/db_engine_specs/bigquery.py
@@ -122,6 +122,8 @@ class BigQueryEngineSpec(BaseEngineSpec):  # pylint: disable=too-many-public-met
 
     allows_hidden_cc_in_orderby = True
 
+    supports_catalog = True
+
     """
     https://www.python.org/dev/peps/pep-0249/#arraysize
     raw_connections bypass the sqlalchemy-bigquery query execution context and deal with
diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py
index e52e69d7e8..44e2c8a1f8 100644
--- a/superset/db_engine_specs/postgres.py
+++ b/superset/db_engine_specs/postgres.py
@@ -96,6 +96,7 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
     engine_name = "PostgreSQL"
 
     supports_dynamic_schema = True
+    supports_catalog = True
 
     _time_grain_expressions = {
         None: "{col}",
diff --git a/superset/db_engine_specs/snowflake.py b/superset/db_engine_specs/snowflake.py
index 033b637e48..8b4c51ee8c 100644
--- a/superset/db_engine_specs/snowflake.py
+++ b/superset/db_engine_specs/snowflake.py
@@ -29,6 +29,7 @@ from flask import current_app
 from flask_babel import gettext as __
 from marshmallow import fields, Schema
 from sqlalchemy import types
+from sqlalchemy.engine.reflection import Inspector
 from sqlalchemy.engine.url import URL
 from typing_extensions import TypedDict
 
@@ -84,6 +85,7 @@ class SnowflakeEngineSpec(PostgresBaseEngineSpec):
     sqlalchemy_uri_placeholder = "snowflake://"
 
     supports_dynamic_schema = True
+    supports_catalog = True
 
     _time_grain_expressions = {
         None: "{col}",
@@ -167,6 +169,24 @@ class SnowflakeEngineSpec(PostgresBaseEngineSpec):
 
         return parse.unquote(database.split("/")[1])
 
+    @classmethod
+    def get_catalog_names(
+        cls,
+        database: "Database",
+        inspector: Inspector,
+    ) -> List[str]:
+        """
+        Return all catalogs.
+
+        In Snowflake, a catalog is called a "database".
+        """
+        return sorted(
+            catalog
+            for (catalog,) in inspector.bind.execute(
+                "SELECT DATABASE_NAME from information_schema.databases"
+            )
+        )
+
     @classmethod
     def epoch_to_dttm(cls) -> str:
         return "DATEADD(S, {col}, '1970-01-01')"