dongjoon-hyun opened a new pull request, #60343:
URL: https://github.com/apache/spark/pull/60343

   ### What changes were proposed in this pull request?
   
   This PR aims to fix `ParquetColumnVector.reset()` to skip only missing 
columns, so that the repetition and definition levels of a `NullType` column 
are reset for each batch.
   
   Since SPARK-54220 (#52922), `WritableColumnVector.isAllNull()` is true for a 
`NullType` column as well as for a missing column, and 
`ParquetColumnVector.reset()` returns early for both. However, a `NullType` 
column in the file still has a column reader, which writes its repetition and 
definition levels for each batch. A parent struct shares and resets only the 
levels of its last non-missing field. So, the levels of a `NullType` field that 
is not the last field, e.g. `n` in `array<struct<n: void, a: int>>`, are never 
reset.
   
   `assemble()` keeps its `isAllNull()` check because it does nothing for a 
primitive column like a `NullType` column.
   
   ### Why are the changes needed?
   
   Inside an array or a map, the column reader appends to these level vectors, 
so they grow with every batch and hold all levels of the file split until the 
reader is closed. For example, after reading 1,000,000 rows of `array<struct<n: 
void, a: int>>` with 4 elements each (a 9.2 MB file), each level vector of `n` 
holds 4,000,000 integers (about 16 MB), while those of `a` stay at the batch 
size.
   
   This bug exists since Apache Spark 4.1.0 
([v4.1.0](https://github.com/apache/spark/releases/tag/v4.1.0), 2025-12-11).
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. The query results are the same. Only the memory usage of the vectorized 
Parquet reader is fixed for such schemas.
   
   ### How was this patch tested?
   
   Pass the CIs with the newly added test case. Without this fix, the new test 
case fails like the following.
   
   ```
   - SPARK-61460: Vectorized reader resets the levels of a NullType field for 
each batch *** FAILED ***
     2 did not equal 1 (ParquetVectorizedSuite.scala:907)
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   


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