Skip to content

Commit 04088cb

Browse files
authored
Catalog tests around nonexistent tables + namespaces (#2990)
<!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change More catalog tests! I wanted to add tests around renaming nonexistent tables/namespaces, as well as loading nonexistent tables. The great news is that these are working as intended across all of our catalogs! ## Are these changes tested? Just tests. ## Are there any user-facing changes? Just tests. <!-- In the case of user-facing changes, please add the changelog label. -->
1 parent d62b360 commit 04088cb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/integration/test_catalog.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,3 +823,40 @@ def test_drop_nonexistent_namespace(test_catalog: Catalog) -> None:
823823
namespace = ("non_existent_namespace",)
824824
with pytest.raises(NoSuchNamespaceError):
825825
test_catalog.drop_namespace(namespace)
826+
827+
828+
@pytest.mark.integration
829+
@pytest.mark.parametrize("test_catalog", CATALOGS)
830+
def test_rename_table_missing_source_table(test_catalog: Catalog, table_name: str, database_name: str) -> None:
831+
test_catalog.create_namespace_if_not_exists(database_name)
832+
identifier = (database_name, table_name)
833+
new_identifier = (database_name, f"rename-{table_name}")
834+
835+
with pytest.raises(NoSuchTableError):
836+
test_catalog.rename_table(identifier, new_identifier)
837+
838+
839+
@pytest.mark.integration
840+
@pytest.mark.parametrize("test_catalog", CATALOGS)
841+
def test_rename_table_destination_namespace_missing(
842+
test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str
843+
) -> None:
844+
test_catalog.create_namespace_if_not_exists(database_name)
845+
identifier = (database_name, table_name)
846+
test_catalog.create_table(identifier, table_schema_nested)
847+
848+
new_database_name = "non_existent_namespace"
849+
new_identifier = (new_database_name, table_name)
850+
851+
with pytest.raises(NoSuchNamespaceError):
852+
test_catalog.rename_table(identifier, new_identifier)
853+
854+
855+
@pytest.mark.integration
856+
@pytest.mark.parametrize("test_catalog", CATALOGS)
857+
def test_load_missing_table(test_catalog: Catalog, database_name: str, table_name: str) -> None:
858+
test_catalog.create_namespace_if_not_exists(database_name)
859+
identifier = (database_name, table_name)
860+
861+
with pytest.raises(NoSuchTableError):
862+
test_catalog.load_table(identifier)

0 commit comments

Comments
 (0)