diff --git a/superset/examples/birth_names.py b/superset/examples/birth_names.py index fa9d188040e1c..4a4da1cc74917 100644 --- a/superset/examples/birth_names.py +++ b/superset/examples/birth_names.py @@ -106,7 +106,7 @@ def load_birth_names( schema = inspect(engine).default_schema_name tbl_name = "birth_names" - table_exists = database.has_table_by_name(tbl_name) + table_exists = database.has_table_by_name(tbl_name, schema=schema) if not only_metadata and (not table_exists or force): load_data(tbl_name, database, sample=sample) diff --git a/tests/integration_tests/datasource_tests.py b/tests/integration_tests/datasource_tests.py index 2c64d7c03c060..f684304162dd7 100644 --- a/tests/integration_tests/datasource_tests.py +++ b/tests/integration_tests/datasource_tests.py @@ -21,6 +21,7 @@ import prison import pytest +from sqlalchemy import inspect from superset import app, ConnectorRegistry, db from superset.connectors.sqla.models import SqlaTable @@ -278,8 +279,12 @@ def save_datasource_from_dict(self, datasource_post): @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") def test_change_database(self): + database = get_example_database() + engine = database.get_sqla_engine() + schema = inspect(engine).default_schema_name + self.login(username="admin") - tbl = self.get_table(name="birth_names") + tbl = self.get_table(name="birth_names", schema=schema) tbl_id = tbl.id db_id = tbl.database_id datasource_post = get_datasource_post()