feat(snowflake): get_catalog_names (#23602)

This commit is contained in:
Beto Dealmeida 2023-04-06 12:17:30 -07:00 committed by GitHub
parent 290920c4fb
commit 8d14420d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -96,6 +96,7 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
engine_name = "PostgreSQL"
supports_dynamic_schema = True
supports_catalog = True
_time_grain_expressions = {
None: "{col}",

View File

@ -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')"