This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new c486040  [SPARK-36789][SQL] Use the correct constant type as the null 
value holder in array functions
c486040 is described below

commit c4860402afc2f48aca3ff81144490021434fa530
Author: Wenchen Fan <[email protected]>
AuthorDate: Fri Sep 17 16:49:54 2021 +0900

    [SPARK-36789][SQL] Use the correct constant type as the null value holder 
in array functions
    
    ### What changes were proposed in this pull request?
    
    In array functions, we use constant 0 as the placeholder when adding a null 
value to an array buffer. This PR makes sure the constant 0 matches the type of 
the array element.
    
    ### Why are the changes needed?
    
    Fix a potential bug. Somehow we can hit this bug sometimes after 
https://github.com/apache/spark/pull/33955 .
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    existing tests
    
    Closes #34029 from cloud-fan/minor.
    
    Authored-by: Wenchen Fan <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
    (cherry picked from commit 4145498826f288e610b00033d9fc2063fd1acc9f)
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 .../apache/spark/sql/catalyst/expressions/collectionOperations.scala  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
index 9f922d1..e273c60 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
@@ -3127,7 +3127,9 @@ trait ArraySetLike {
   @transient protected lazy val nullValueHolder = et match {
     case ByteType => "(byte) 0"
     case ShortType => "(short) 0"
-    case LongType => "(long) 0"
+    case LongType => "0L"
+    case FloatType => "0.0f"
+    case DoubleType => "0.0"
     case _ => "0"
   }
 

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

Reply via email to