Skip to content

Commit b11cdb5

Browse files
authored
Deprecate to_requested_schema (#918)
* deprecate to_requested_schema * prep for release
1 parent a3dd531 commit b11cdb5

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

mkdocs/docs/how-to-release.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ The guide to release PyIceberg.
2323

2424
The first step is to publish a release candidate (RC) and publish it to the public for testing and validation. Once the vote has passed on the RC, the RC turns into the new release.
2525

26+
## Preparing for a release
27+
28+
Before running the release candidate, we want to remove any APIs that were marked for removal under the @deprecated tag for this release.
29+
30+
For example, the API with the following deprecation tag should be removed when preparing for the 0.2.0 release.
31+
32+
```python
33+
34+
@deprecated(
35+
deprecated_in="0.1.0",
36+
removed_in="0.2.0",
37+
help_message="Please use load_something_else() instead",
38+
)
39+
```
40+
2641
## Running a release candidate
2742

2843
Make sure that the version is correct in `pyproject.toml` and `pyiceberg/__init__.py`. Correct means that it reflects the version that you want to release.

pyiceberg/io/pyarrow.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
from pyiceberg.utils.concurrent import ExecutorFactory
157157
from pyiceberg.utils.config import Config
158158
from pyiceberg.utils.datetime import millis_to_datetime
159+
from pyiceberg.utils.deprecated import deprecated
159160
from pyiceberg.utils.singleton import Singleton
160161
from pyiceberg.utils.truncate import truncate_upper_bound_binary_string, truncate_upper_bound_text_string
161162

@@ -1279,6 +1280,23 @@ def project_batches(
12791280
total_row_count += len(batch)
12801281

12811282

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+
12821300
def _to_requested_schema(
12831301
requested_schema: Schema,
12841302
file_schema: Schema,
@@ -1434,6 +1452,8 @@ def field_partner(self, partner_struct: Optional[pa.Array], field_id: int, _: st
14341452

14351453
if isinstance(partner_struct, pa.StructArray):
14361454
return partner_struct.field(name)
1455+
elif isinstance(partner_struct, pa.Table):
1456+
return partner_struct.column(name).combine_chunks()
14371457
elif isinstance(partner_struct, pa.RecordBatch):
14381458
return partner_struct.column(name)
14391459
else:

0 commit comments

Comments
 (0)