mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat: add support for catalogs (#28416)
This commit is contained in:
@@ -155,3 +155,91 @@ def test_where_latest_partition(
|
||||
)
|
||||
|
||||
assert str(actual) == expected
|
||||
|
||||
|
||||
def test_adjust_engine_params_fully_qualified() -> None:
|
||||
"""
|
||||
Test the ``adjust_engine_params`` method when the URL has catalog and schema.
|
||||
"""
|
||||
from superset.db_engine_specs.presto import PrestoEngineSpec
|
||||
|
||||
url = make_url("presto://localhost:8080/hive/default")
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(url, {})[0]
|
||||
assert str(uri) == "presto://localhost:8080/hive/default"
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(
|
||||
url,
|
||||
{},
|
||||
schema="new_schema",
|
||||
)[0]
|
||||
assert str(uri) == "presto://localhost:8080/hive/new_schema"
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(
|
||||
url,
|
||||
{},
|
||||
catalog="new_catalog",
|
||||
)[0]
|
||||
assert str(uri) == "presto://localhost:8080/new_catalog/default"
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(
|
||||
url,
|
||||
{},
|
||||
catalog="new_catalog",
|
||||
schema="new_schema",
|
||||
)[0]
|
||||
assert str(uri) == "presto://localhost:8080/new_catalog/new_schema"
|
||||
|
||||
|
||||
def test_adjust_engine_params_catalog_only() -> None:
|
||||
"""
|
||||
Test the ``adjust_engine_params`` method when the URL has only the catalog.
|
||||
"""
|
||||
from superset.db_engine_specs.presto import PrestoEngineSpec
|
||||
|
||||
url = make_url("presto://localhost:8080/hive")
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(url, {})[0]
|
||||
assert str(uri) == "presto://localhost:8080/hive"
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(
|
||||
url,
|
||||
{},
|
||||
schema="new_schema",
|
||||
)[0]
|
||||
assert str(uri) == "presto://localhost:8080/hive/new_schema"
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(
|
||||
url,
|
||||
{},
|
||||
catalog="new_catalog",
|
||||
)[0]
|
||||
assert str(uri) == "presto://localhost:8080/new_catalog"
|
||||
|
||||
uri = PrestoEngineSpec.adjust_engine_params(
|
||||
url,
|
||||
{},
|
||||
catalog="new_catalog",
|
||||
schema="new_schema",
|
||||
)[0]
|
||||
assert str(uri) == "presto://localhost:8080/new_catalog/new_schema"
|
||||
|
||||
|
||||
def test_get_default_catalog() -> None:
|
||||
"""
|
||||
Test the ``get_default_catalog`` method.
|
||||
"""
|
||||
from superset.db_engine_specs.presto import PrestoEngineSpec
|
||||
from superset.models.core import Database
|
||||
|
||||
database = Database(
|
||||
database_name="my_db",
|
||||
sqlalchemy_uri="presto://localhost:8080/hive",
|
||||
)
|
||||
assert PrestoEngineSpec.get_default_catalog(database) == "hive"
|
||||
|
||||
database = Database(
|
||||
database_name="my_db",
|
||||
sqlalchemy_uri="presto://localhost:8080/hive/default",
|
||||
)
|
||||
assert PrestoEngineSpec.get_default_catalog(database) == "hive"
|
||||
|
||||
Reference in New Issue
Block a user