LuciferYang opened a new pull request, #55896: URL: https://github.com/apache/spark/pull/55896
### What changes were proposed in this pull request? Backport of #55890 (master) / #55894 (branch-4.2) to `branch-4.1`. Cherry-pick applied cleanly with no manual conflict resolution; patch content is byte-identical to the branch-4.2 backport. `DowncastLongUpdater.decodeSingleDictionaryId` calls `values.putLong(...)`, but `DowncastLongUpdater` is only chosen when the target is a 32-bit Decimal (precision <= 9), whose column vector stores into `intData`, not `longData`. So `putLong` NPEs whenever this path runs. Switch the call to `putInt` with the same `(int) longValue` narrowing cast already used by `readValue` and `readValues`. ### Why are the changes needed? The bug has been latent since SPARK-35640 (Jun 2021). The path is only reachable when all three conditions hold: 1. Parquet stores the column as INT64 + DECIMAL(p<=9). Spark's own writer emits INT32 for this case, so the file must come from another writer (Hive, Impala, ...). 2. Spark reads it as a Decimal with precision <= 9. 3. The vectorized reader has to eagerly drain buffered dictionary IDs -- typically when parquet-mr writes the column as a mix of dictionary-encoded and PLAIN pages and a non-dict page follows a dict page in the same batch. The normal lazy-dictionary path decodes at row read time via `ParquetDictionary` and never touches this updater method. ### Does this PR introduce _any_ user-facing change? Yes. Reads that previously NPE'd now return correct values. ### How was this patch tested? Same regression test from #55890 / #55894. Local sbt couldn't download artifacts due to transient network timeouts, so verification is via GHA on this PR. The branch-4.2 backport of the same patch passed locally (`build/sbt 'sql/testOnly *ParquetIOSuite -- -z "SPARK-56872"'`) and is in #55894. ### Was this patch authored or co-authored using generative AI tooling? No -- 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]
