uros-b commented on code in PR #58149:
URL: https://github.com/apache/spark/pull/58149#discussion_r3956650744


##########
sql/core/src/test/resources/sql-tests/inputs/vector-norm.sql:
##########
@@ -186,3 +186,29 @@ SELECT vector_norm(array(float('inf'), 1.0F), 2.0F);
 
 -- vector_normalize: dividing by an infinite norm yields NaN for the infinite 
element
 SELECT vector_normalize(array(float('inf'), 1.0F), 2.0F);
+
+-- SPARK-58897: NaN elements propagate through the norm, following the 
convention of max and
+-- array_max that NaN compares as larger than any other value
+
+-- vector_norm: a NaN element makes the infinity norm NaN, not the largest of 
the other elements
+SELECT vector_norm(array(float('nan')), float('inf'));
+SELECT vector_norm(array(float('nan'), 5.0F), float('inf'));
+SELECT vector_norm(array(5.0F, float('nan')), float('inf'));
+SELECT vector_norm(array(float('nan'), float('inf')), float('inf'));
+
+-- vector_norm: the L1 and L2 norms propagate NaN in the same way
+SELECT vector_norm(array(float('nan'), 5.0F), 1.0F);
+SELECT vector_norm(array(float('nan'), 5.0F), 2.0F);
+
+-- vector_norm: a NaN element in the unrolled section of a large vector

Review Comment:
   The added comment says "a NaN element in the unrolled section" but the 
infinity-norm path is a plain scalar loop.



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