|
156 | 156 | from pyiceberg.utils.concurrent import ExecutorFactory
|
157 | 157 | from pyiceberg.utils.config import Config
|
158 | 158 | from pyiceberg.utils.datetime import millis_to_datetime
|
| 159 | +from pyiceberg.utils.deprecated import deprecated |
159 | 160 | from pyiceberg.utils.singleton import Singleton
|
160 | 161 | from pyiceberg.utils.truncate import truncate_upper_bound_binary_string, truncate_upper_bound_text_string
|
161 | 162 |
|
@@ -1279,6 +1280,23 @@ def project_batches(
|
1279 | 1280 | total_row_count += len(batch)
|
1280 | 1281 |
|
1281 | 1282 |
|
| 1283 | +@deprecated( |
| 1284 | + deprecated_in="0.7.0", |
| 1285 | + removed_in="0.8.0", |
| 1286 | + help_message="The public API for 'to_requested_schema' is deprecated and is replaced by '_to_requested_schema'", |
| 1287 | +) |
| 1288 | +def to_requested_schema(requested_schema: Schema, file_schema: Schema, table: pa.Table) -> pa.Table: |
| 1289 | + struct_array = visit_with_partner(requested_schema, table, ArrowProjectionVisitor(file_schema), ArrowAccessor(file_schema)) |
| 1290 | + |
| 1291 | + arrays = [] |
| 1292 | + fields = [] |
| 1293 | + for pos, field in enumerate(requested_schema.fields): |
| 1294 | + array = struct_array.field(pos) |
| 1295 | + arrays.append(array) |
| 1296 | + fields.append(pa.field(field.name, array.type, field.optional)) |
| 1297 | + return pa.Table.from_arrays(arrays, schema=pa.schema(fields)) |
| 1298 | + |
| 1299 | + |
1282 | 1300 | def _to_requested_schema(
|
1283 | 1301 | requested_schema: Schema,
|
1284 | 1302 | file_schema: Schema,
|
@@ -1434,6 +1452,8 @@ def field_partner(self, partner_struct: Optional[pa.Array], field_id: int, _: st
|
1434 | 1452 |
|
1435 | 1453 | if isinstance(partner_struct, pa.StructArray):
|
1436 | 1454 | return partner_struct.field(name)
|
| 1455 | + elif isinstance(partner_struct, pa.Table): |
| 1456 | + return partner_struct.column(name).combine_chunks() |
1437 | 1457 | elif isinstance(partner_struct, pa.RecordBatch):
|
1438 | 1458 | return partner_struct.column(name)
|
1439 | 1459 | else:
|
|
0 commit comments