|
16 | 16 | # under the License. |
17 | 17 |
|
18 | 18 | import os |
| 19 | +import uuid |
19 | 20 | from collections.abc import Generator |
20 | 21 | from pathlib import Path, PosixPath |
21 | 22 |
|
@@ -601,3 +602,36 @@ def test_register_table_existing(test_catalog: Catalog, table_schema_nested: Sch |
601 | 602 | # Assert that registering the table again raises TableAlreadyExistsError |
602 | 603 | with pytest.raises(TableAlreadyExistsError): |
603 | 604 | test_catalog.register_table(identifier, metadata_location=table.metadata_location) |
| 605 | + |
| 606 | + |
| 607 | +@pytest.mark.integration |
| 608 | +def test_rest_custom_namespace_separator(rest_catalog: Catalog, table_schema_simple: Schema): |
| 609 | + """ |
| 610 | + Tests that the REST catalog correctly picks up the namespace-separator from the config endpoint. |
| 611 | + The REST Catalog is configured with a '.' namespace separator. |
| 612 | + """ |
| 613 | + assert rest_catalog._namespace_separator == "." |
| 614 | + |
| 615 | + unique_id = uuid.uuid4().hex |
| 616 | + parent_namespace = (f"test_parent_{unique_id}",) |
| 617 | + child_namespace_part = "child" |
| 618 | + full_namespace_tuple = (*parent_namespace, child_namespace_part) |
| 619 | + |
| 620 | + table_name = "my_table" |
| 621 | + full_table_identifier_tuple = (*full_namespace_tuple, table_name) |
| 622 | + |
| 623 | + rest_catalog.create_namespace(namespace=parent_namespace) |
| 624 | + rest_catalog.create_namespace(namespace=full_namespace_tuple) |
| 625 | + |
| 626 | + namespaces = rest_catalog.list_namespaces(parent_namespace) |
| 627 | + assert full_namespace_tuple in namespaces |
| 628 | + |
| 629 | + # Test with a table |
| 630 | + table = rest_catalog.create_table(identifier=full_table_identifier_tuple, schema=table_schema_simple) |
| 631 | + assert table.identifier == full_table_identifier_tuple |
| 632 | + |
| 633 | + tables = rest_catalog.list_tables(full_namespace_tuple) |
| 634 | + assert full_table_identifier_tuple in tables |
| 635 | + |
| 636 | + loaded_table = rest_catalog.load_table(identifier=full_table_identifier_tuple) |
| 637 | + assert loaded_table.identifier == full_table_identifier_tuple |
0 commit comments