Mithilbatra opened a new pull request, #19157:
URL: https://github.com/apache/iceberg/pull/19157

   Fixes #19137.
   
   After `ALTER TABLE ... DROP COLUMN s.a` removes the only field of `s 
STRUCT<a INT>`, reading existing ORC files fails with:
   
       IllegalArgumentException: Missing ORC reader for field s (2)
   
   Parquet returns the row with an empty struct.
   
   **Why:** `ORC.ReadBuilder.build()` removes constant and metadata columns 
with `TypeUtil.selectNot`, which rebuilds the schema from leaf field ids only. 
A struct with no projected fields has no leaves, so it was pruned from the ORC 
read schema, while the value reader is built from the full expected schema and 
expects it.
   
   **What:** Build the projection from primitive, struct and variant field ids 
(this includes list element and map value structs), minus the excluded ids, and 
use `TypeUtil.project`. `PruneColumns` already turns a selected struct without 
selected sub-fields into an empty struct. List/map ids are left out because 
`project` doesn't accept them, and a file-type field keeps projecting through 
its leaves as before.
   
   **How tested:**
   - New `TestOrcStructWithoutProjectedFields` (generic ORC reader): top-level 
struct, list element struct, map value struct, including null structs, null 
elements/values and empty lists. All three fail on main.
   - `:iceberg-orc:check` and `:iceberg-data:test` pass.
   - Applied the tests from #19153 locally with the ORC `assumeThat` removed: 
ORC passes for the generic, Spark 4.2 and Flink 2.3 readers (Parquet still 
fails there until #19153's fix lands). I did not include that change here to 
avoid conflicting with #19153. Once both are merged, the ORC skip there can be 
dropped.
   
   Related: #19153 (Parquet side, #19138).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to