HonahX commented on code in PR #305:
URL: https://github.com/apache/iceberg-python/pull/305#discussion_r1468964393


##########
tests/catalog/test_base.py:
##########
@@ -330,6 +333,34 @@ def test_create_table(catalog: InMemoryCatalog) -> None:
     assert catalog.load_table(TEST_TABLE_IDENTIFIER) == table
 
 
+@pytest.mark.parametrize(
+    "schema_fixture,expected_fixture",
+    [
+        ("pyarrow_schema_simple_without_ids", "iceberg_schema_simple"),
+        ("iceberg_schema_simple", "iceberg_schema_simple"),
+        ("iceberg_schema_nested", "iceberg_schema_nested"),
+        ("pyarrow_schema_nested_without_ids", "iceberg_schema_nested"),
+    ],
+)
+def test_convert_schema_if_needed(
+    schema_fixture: str, expected_fixture: str, catalog: InMemoryCatalog, 
request: pytest.FixtureRequest
+) -> None:
+    schema = request.getfixturevalue(schema_fixture)
+    expected = request.getfixturevalue(expected_fixture)
+    assert expected == catalog._convert_schema_if_needed(schema)
+
+
+def test_create_table_pyarrow_schema(catalog: InMemoryCatalog, 
pyarrow_schema_simple_without_ids: pa.Schema) -> None:

Review Comment:
   How about combining this with the above test, so that we only need to verify 
if the created table contain the expected schema:
   ```python
   table = catalog.create_table(identifier..., schema=pyarrow_schema)
   assert table.schema() == expected_schema
   ```
   I think it is better to test the API directly instead of the internal method 
when possible. This might also resolve your concern about creating expected 
outcome for the "random" id assigned by whatever approach we finally choose to 
implement the `_convert_schema_if_needed`. WDYT?
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to