iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Arrow: Fix NPE reading a constant/null column in vectorized reader

Open thswlsqls opened this issue 5 months ago • 1 comments

Closes #10275

Summary

  • When a column is added with ALTER TABLE ... ADD COLUMN after data files were written, the arrow vectorized reader produces a constant VectorHolder whose vector is null.
  • GenericArrowVectorAccessorFactory.getPlainVectorAccessor called vector.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 the default branch 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 via updateSchema().addColumn, scans with VectorizedTableScanIterable, and asserts UnsupportedOperationException with message Unsupported vector: null.
  • Verified the test fails on main (NPE on vector.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

thswlsqls avatar Jun 19 '26 05:06 thswlsqls

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."

thswlsqls avatar Jun 24 '26 20:06 thswlsqls