miland-db opened a new pull request, #54267:
URL: https://github.com/apache/spark/pull/54267

   ### What changes were proposed in this pull request?
   Added a null-safe `findPivotIndex` lookup method that returns `-1` for null 
keys on the `TreeMap` path, since `null` can never be a valid `TreeMap` key. 
The `HashMap` path (atomic types) is unchanged, as it handles `null` keys 
safely and allows null as a valid pivot value.
   
   
   ### Why are the changes needed?
   When a `PIVOT` query uses a non-atomic pivot column (struct, array), 
`PivotFirst` stores pivot values in a `TreeMap` with a comparison-based 
ordering. If the pivot column contains null values (e.g., from a GROUP BY null 
group), the `TreeMap.getOrElse` lookup calls `compare(null, existingKey)`, 
which throws a `NullPointerException`.
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   
   ### How was this patch tested?
   Added unit test in `DataFramePivotSuite.scala`.
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No.
   Please refer to the [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


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