viirya opened a new pull request, #60324: URL: https://github.com/apache/spark/pull/60324
### What changes were proposed in this pull request? This is a follow-up of #59582, addressing the two non-blocking items in https://github.com/apache/spark/pull/59582#pullrequestreview-5853478685. 1. Reused `NullType` column vectors no longer grow across batches. - `RowToColumnConverter` uses the no-op `NullConverter` directly for a nullable `NullType` field, instead of wrapping it in `BasicNullableTypeConverter`, which called `appendNull()` for every row. - `WritableColumnVector.reset()` now clears `elementsAppended` of an all-null vector (`NullType` or missing column) before returning early. A null struct still appends a null to each of its children (`appendStruct(true)`), so a `NullType` field of a nullable struct grew the same way, which the converter change alone does not cover. 2. With `emptyBatches`, `ArrowBackedPartitionReader` in the test data source always returns `ArrowBackedDataSourceV2.NUM_EMPTY_BATCHES` (3) batches without rows. The positions are now kept in a queue instead of a set, so they are not deduplicated when they coincide (fewer than two batches). `ArrowColumnarPythonUDFSuite` uses the constant instead of a literal `3`. ### Why are the changes needed? `WritableColumnVector.reset()` returns early for an all-null vector (since SPARK-54220), so `elementsAppended` is never cleared for a `NullType` vector. When the vectors are reused across batches, by `rowsToColumnarBatches` in `ColumnarArrowEvalPythonEvaluatorFactory` and by `RowToColumnarExec`, every row with a null `NullType` value, or a null struct with a `NullType` field, grows it. Nothing is allocated for the vector, but after about 2^31 rows in one task `reserve` fails with "Cannot reserve additional contiguous bytes". The test data source fix keeps the number of empty batches independent of the reader's parameters, so the test does not silently break if its parameters change. ### Does this PR introduce _any_ user-facing change? No. `NullType` support in `RowToColumnConverter` was added by #59582, which is not released yet. ### How was this patch tested? New test in `RowToColumnConverterSuite`: converts rows with a nullable `NullType` column and a nullable struct with a `NullType` field into reused vectors over several batches with `reset()` in between. It fails without either change (`10 did not equal 0` for the top-level column without the converter change, `15 was not less than or equal to 10` for the struct child without the `reset()` change). Ran `RowToColumnConverterSuite`, `ArrowColumnarPythonUDFSuite`, `ArrowCachedPythonUDFSuite`, `ColumnarBatchSuite`, and, for the `reset()` change, `ParquetIOSuite`, `ParquetSchemaSuite` and `FileBasedDataSourceSuite`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) This pull request and its description were written by Isaac. -- 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]
