Skip to content

REST scan planning drops data file lower/upper bounds and key metadata #4528

Backlog

Description

@Shahzeb-DataEngineer

Apache Iceberg version

main (development)

Please describe the bug 🐞

Version: PyIceberg main at commit c73bee8 (2026-11-29).

When a REST catalog plans a scan server-side, the server can return per-column lower and upper bounds and key metadata on each data file. PyIceberg parses those fields into RESTDataFile (lower-bounds, upper-bounds) and RESTContentFile (key-metadata), but _rest_file_to_data_file in pyiceberg/table/init.py never passes them to DataFile.from_args. The converted DataFile therefore always has lower_bounds=None, upper_bounds=None and key_metadata=None.

Repro:

import base64
from pyiceberg.catalog.rest.scan_planning import RESTFileScanTask
from pyiceberg.table import FileScanTask

rest_task = RESTFileScanTask.model_validate(
    {
        "data-file": {
            "spec-id": 0,
            "content": "data",
            "file-path": "s3://bucket/table/data/file.parquet",
            "file-format": "parquet",
            "file-size-in-bytes": 1024,
            "record-count": 100,
            "lower-bounds": {"keys": [1], "values": [10]},
            "upper-bounds": {"keys": [1], "values": [20]},
            "key-metadata": base64.b64encode(b"test-key-metadata").decode(),
        }
    }
)
task = FileScanTask.from_rest_response(rest_task, [])
print(task.file.lower_bounds)   # None, expected {1: b'\n\x00\x00\x00'}
print(task.file.upper_bounds)   # None, expected {1: b'\x14\x00\x00\x00'}
print(task.file.key_metadata)   # None, expected b'test-key-metadata'

Impact:

  • Planned tasks carry no column bounds, so nothing downstream can prune on them even though the server sent them.
  • For encrypted tables, the missing key metadata means no decryption properties are built and reading the planned files fails.

Fix sketch: forward the three fields in _rest_file_to_data_file. Bounds arrive as primitive values and need serializing with pyiceberg.conversions.to_bytes using the table schema field types, and key metadata arrives as a base64 string and needs decoding to bytes, matching the existing encrypted-key-metadata handling in table/metadata.py.

Related to #2775 and #2792.

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

  1. SurenderguliaEnginner commented on Nov 30, 2026

    @SurenderguliaEnginner

    Hi @Shahzeb-DataEngineer, thanks for reporting this!

    I can reproduce the issue: _rest_file_to_data_file in pyiceberg/table/__init__.py omits lower_bounds, upper_bounds, and key_metadata when converting RESTDataFile to DataFile.from_args().

    I would like to work on this and submit a PR with unit tests covering REST scan planning metadata preservation. Could you please assign this to me? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions