syun64 commented on code in PR #305: URL: https://github.com/apache/iceberg-python/pull/305#discussion_r1468603355
########## pyiceberg/catalog/__init__.py: ########## @@ -512,6 +516,22 @@ def _check_for_overlap(removals: Optional[Set[str]], updates: Properties) -> Non if overlap: raise ValueError(f"Updates and deletes have an overlap: {overlap}") + @staticmethod + def _convert_schema_if_needed(schema: Union[Schema, "pa.Schema"]) -> Schema: + try: Review Comment: Are you suggesting the following instead? ``` if isinstance(schema, Schema): return schema try: import pyarrow as pa from pyiceberg.io.pyarrow import _ConvertToIcebergWithFreshIds, pre_order_visit_pyarrow if isinstance(schema, pa.Schema): schema: Schema = pre_order_visit_pyarrow(schema, _ConvertToIcebergWithFreshIds()) # type: ignore return schema except ModuleNotFoundError: pass raise ValueError(f"{type(schema)=} must be pyiceberg.schema.Schema") ``` Maybe it is better, since we avoid checking for the import if the type is already correct -- 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