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


##########
sql/core/src/test/resources/sql-tests/inputs/math.sql:
##########
@@ -70,6 +70,34 @@ SELECT bround(525L, -3);
 SELECT bround(9223372036854775807L, -1);
 SELECT bround(-9223372036854775808L, -1);
 
+-- Truncate with Byte input
+SELECT truncate(25y, 1);
+SELECT truncate(25y, 0);
+SELECT truncate(25y, -1);
+SELECT truncate(25y, -2);
+SELECT truncate(25y, -3);
+
+-- Truncate with short integer input
+SELECT truncate(525s, 1);
+SELECT truncate(525s, 0);
+SELECT truncate(525s, -1);
+SELECT truncate(525s, -2);
+SELECT truncate(525s, -3);
+
+-- Truncate with integer input
+SELECT truncate(525, 1);
+SELECT truncate(525, 0);
+SELECT truncate(525, -1);
+SELECT truncate(525, -2);
+SELECT truncate(525, -3);
+
+-- Truncate with big integer input
+SELECT truncate(525L, 1);
+SELECT truncate(525L, 0);
+SELECT truncate(525L, -1);
+SELECT truncate(525L, -2);
+SELECT truncate(525L, -3);
+

Review Comment:
   Every new math.sql case uses a positive input. All twenty are 25 or 525. 
Truncating toward zero instead of toward negative infinity is the entire reason 
this function exists, and no golden case exercises it: truncate(-25y, -1) is 
-20 where floor(-25y, -1) is -30. Mirroring the existing inputs from round was 
the right instinct, but it mechanically inherited round's all-positive inputs, 
which for this function drops the interesting half of the behavior.



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