Skip to content

Commit 93b61dd

Browse files
committed
use schema_to_pyarrow directly for backporting
1 parent 56899e6 commit 93b61dd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pyiceberg/io/pyarrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ def write_file(table: Table, tasks: Iterator[WriteTask]) -> Iterator[DataFile]:
17311731
parquet_writer_kwargs = _get_parquet_writer_kwargs(table.properties)
17321732

17331733
file_path = f'{table.location()}/data/{task.generate_data_file_filename("parquet")}'
1734-
file_schema = table.schema().as_arrow()
1734+
file_schema = schema_to_pyarrow(table.schema())
17351735

17361736
fo = table.io.new_output(file_path)
17371737
row_group_size = PropertyUtil.property_as_int(

pyiceberg/table/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,12 @@ def append(self, df: pa.Table) -> None:
10531053
if len(self.spec().fields) > 0:
10541054
raise ValueError("Cannot write to partitioned tables")
10551055

1056+
from pyiceberg.io.pyarrow import schema_to_pyarrow
1057+
10561058
_check_schema_compatible(self.schema(), other_schema=df.schema)
10571059
# cast if the two schemas are compatible but not equal
1058-
if self.schema().as_arrow() != df.schema:
1059-
df = df.cast(self.schema().as_arrow())
1060+
if schema_to_pyarrow(self.schema()) != df.schema:
1061+
df = df.cast(schema_to_pyarrow(self.schema()))
10601062

10611063
merge = _MergingSnapshotProducer(operation=Operation.APPEND, table=self)
10621064

@@ -1091,10 +1093,12 @@ def overwrite(self, df: pa.Table, overwrite_filter: BooleanExpression = ALWAYS_T
10911093
if len(self.spec().fields) > 0:
10921094
raise ValueError("Cannot write to partitioned tables")
10931095

1096+
from pyiceberg.io.pyarrow import schema_to_pyarrow
1097+
10941098
_check_schema_compatible(self.schema(), other_schema=df.schema)
10951099
# cast if the two schemas are compatible but not equal
1096-
if self.schema().as_arrow() != df.schema:
1097-
df = df.cast(self.schema().as_arrow())
1100+
if schema_to_pyarrow(self.schema()) != df.schema:
1101+
df = df.cast(schema_to_pyarrow(self.schema()))
10981102

10991103
merge = _MergingSnapshotProducer(
11001104
operation=Operation.OVERWRITE if self.current_snapshot() is not None else Operation.APPEND,

0 commit comments

Comments
 (0)