HonahX commented on code in PR #305: URL: https://github.com/apache/iceberg-python/pull/305#discussion_r1470463965
########## tests/catalog/test_base.py: ########## @@ -330,6 +334,34 @@ def test_create_table(catalog: InMemoryCatalog) -> None: assert catalog.load_table(TEST_TABLE_IDENTIFIER) == table +@pytest.mark.parametrize( + "schema,expected", + [ + (lazy_fixture("pyarrow_schema_simple_without_ids"), lazy_fixture("iceberg_schema_simple_no_ids")), + (lazy_fixture("iceberg_schema_simple"), lazy_fixture("iceberg_schema_simple")), + (lazy_fixture("iceberg_schema_nested"), lazy_fixture("iceberg_schema_nested")), + (lazy_fixture("pyarrow_schema_nested_without_ids"), lazy_fixture("iceberg_schema_nested_no_ids")), + ], +) +def test_convert_schema_if_needed( + schema: Union[Schema, pa.Schema], + expected: Schema, + catalog: InMemoryCatalog, +) -> None: + assert expected == catalog._convert_schema_if_needed(schema) + + +def test_create_table_pyarrow_schema(catalog: InMemoryCatalog, pyarrow_schema_simple_without_ids: pa.Schema) -> None: + table = catalog.create_table( + identifier=TEST_TABLE_IDENTIFIER, + schema=pyarrow_schema_simple_without_ids, + location=TEST_TABLE_LOCATION, + partition_spec=TEST_TABLE_PARTITION_SPEC, + properties=TEST_TABLE_PROPERTIES, + ) + assert catalog.load_table(TEST_TABLE_IDENTIFIER) == table + Review Comment: I think it may be better to have another assertion here: ``` assert table.schema() == iceberg_schema_simple ``` maybe also add fixture parametrization to include the `pyarrow_schema_nested` This is not a big deal. So probably we can discuss/modify this in some follow-up PRs. Currently, `test_sql.py` has covered this case: https://github.com/apache/iceberg-python/pull/305/files#diff-fad2e9bc49f619f03bf0631fce12da1f524c786008dbdfc01a35f6caf19a7c01R161 -- 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