Skip to content

[Python] Reuse column names when aligning Arrow batches - #11704

Open
shortwinds wants to merge 1 commit into
apache:masterfrom
shortwinds:feature/python-schema-name-lookup
Open

shortwinds wants to merge 1 commit into
apache:masterfrom
shortwinds:feature/python-schema-name-lookup

Conversation

@shortwinds

@shortwinds shortwinds commented Dec 5, 2026 •

Copy link
Copy Markdown

Purpose

Fixes 1703
When a batch needs schema alignment, _try_to_pad_batch_by_schema builds the full column-name list and searches it for each output field.

This change gets the names once per batch and uses a set for lookups.

Tests

166 tests passed on Linux with CPython 3.10, using this Python source and a locally built native package:

  • schema_evolution_cast_test.py
  • python_stream_schema_test.py
  • native_iterator_test.py::test_duplicate_arrow_outputs_align_metadata_by_position

Read performance

I ran each build 3 times, reading 30,000 rows per run. The table shows medians.

Build Read time (s) Throughput (rows/s)
Original 19.704 1,522.53
Fixed 12.739 2,354.99

Read time fell 35.3%; throughput rose 54.7%.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Speed up schema alignment for wide Arrow batches

1 participant