iceberg
iceberg copied to clipboard
Arrow: Fix NPE reading a constant/null column in vectorized reader
Closes #10275
Summary
- When a column is added with
ALTER TABLE ... ADD COLUMNafter data files were written, the arrow vectorized reader produces a constantVectorHolderwhose vector is null. GenericArrowVectorAccessorFactory.getPlainVectorAccessorcalledvector.getClass()on that null vector, throwing a confusing NullPointerException.- Guard the null vector so the message becomes
Unsupported vector: null, matching the null-safe pattern already used by thedefaultbranch in the same class (line 178). - Revives the stale fix from #10284, closed by the stale bot (not rejected by design); adds the reproduction test the reviewer requested, with no Spark dependency.
- Fully reading added constant/null columns in the vectorized path is out of scope here and tracked as follow-up on #10275.
Testing done
- Added
TestArrowReader#testReadAddedColumnFailsWithClearMessage: writes one row, adds a column viaupdateSchema().addColumn, scans withVectorizedTableScanIterable, and assertsUnsupportedOperationExceptionwith messageUnsupported vector: null. - Verified the test fails on
main(NPE onvector.getClass()) and passes with the fix. ./gradlew :iceberg-arrow:check— passed (30 tests, JDK 21).
AI Disclosure
- Model: Claude Opus 4.8
- Platform/Tool: Claude Code
You're right — this doesn't make the read succeed; it replaces the confusing NPE (getPlainVectorAccessor calling getClass() on a null vector) with a clear UnsupportedOperationException: Unsupported vector: null. Fully reading an added constant/null column in the vectorized path is still out of scope here and tracked on #10275; the workaround today is to disable vectorized reads. I'll update the description so it reads as "clearer failure, not a successful read."