cloud-fan commented on code in PR #54011:
URL: https://github.com/apache/spark/pull/54011#discussion_r2740115711


##########
sql/core/src/test/resources/sql-tests/inputs/vector-agg.sql:
##########
@@ -0,0 +1,280 @@
+-- Tests for vector aggregation functions: vector_sum, vector_avg
+
+-- Basic functionality tests
+
+-- vector_sum: basic test with VALUES clause
+SELECT vector_sum(col) FROM VALUES (array(1.0F, 2.0F, 3.0F)), (array(4.0F, 
5.0F, 6.0F)) AS tab(col);
+
+-- vector_avg: basic test with VALUES clause
+SELECT vector_avg(col) FROM VALUES (array(1.0F, 2.0F, 3.0F)), (array(3.0F, 
4.0F, 5.0F)) AS tab(col);
+
+-- vector_sum: single vector returns the same vector
+SELECT vector_sum(col) FROM VALUES (array(1.0F, 2.0F, 3.0F)) AS tab(col);
+
+-- vector_avg: single vector returns the same vector
+SELECT vector_avg(col) FROM VALUES (array(1.0F, 2.0F, 3.0F)) AS tab(col);
+
+-- vector_sum: three vectors
+SELECT vector_sum(col) FROM VALUES
+    (array(1.0F, 1.0F)),
+    (array(2.0F, 2.0F)),
+    (array(3.0F, 3.0F)) AS tab(col);
+
+-- vector_avg: three vectors - average is (1+2+3)/3 = 2
+SELECT vector_avg(col) FROM VALUES
+    (array(1.0F, 1.0F)),
+    (array(2.0F, 2.0F)),
+    (array(3.0F, 3.0F)) AS tab(col);
+
+-- Mathematical correctness
+
+-- vector_sum: verify element-wise sum
+SELECT vector_sum(col) FROM VALUES
+    (array(1.0F, 2.0F, 3.0F)),
+    (array(10.0F, 20.0F, 30.0F)) AS tab(col);
+
+-- vector_avg: verify element-wise average
+SELECT vector_avg(col) FROM VALUES
+    (array(0.0F, 0.0F)),
+    (array(10.0F, 20.0F)) AS tab(col);
+
+-- vector_avg: verify with negative values
+SELECT vector_avg(col) FROM VALUES
+    (array(-5.0F, 10.0F)),
+    (array(5.0F, -10.0F)) AS tab(col);

Review Comment:
   IMO this level of details should be tested in `VectorAggSuite` instead.



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