hsiang-c commented on code in PR #18205:
URL: https://github.com/apache/datafusion/pull/18205#discussion_r2462627669


##########
datafusion/sqllogictest/test_files/spark/math/abs.slt:
##########
@@ -23,10 +23,103 @@
 
 ## Original Query: SELECT abs(-1);
 ## PySpark 3.5.5 Result: {'abs(-1)': 1, 'typeof(abs(-1))': 'int', 
'typeof(-1)': 'int'}
-#query
-#SELECT abs(-1::int);
+query I
+SELECT abs(-1::int);
+----
+1
+
+statement ok
+CREATE TABLE test_nullable_integer(
+    c1 TINYINT,
+    c2 SMALLINT,
+    c3 INT,
+    c4 BIGINT,
+    dataset TEXT
+    )
+    AS VALUES
+    (NULL, NULL, NULL, NULL, 'nulls'),
+    (0, 0, 0, 0, 'zeros'),
+    (1, 1, 1, 1, 'ones');
+
+query I
+INSERT into test_nullable_integer values(-128, -32768, -2147483648, 
-9223372036854775808, 'mins');
+----
+1
+
+# abs: signed int minimal values
+query IIII
+select abs(c1), abs(c2), abs(c3), abs(c4) from test_nullable_integer where 
dataset = 'mins'

Review Comment:
   Doing `abs(-128)`, `abs(-32768)` and `abs(-2147483648)` doesn't work b/c 
type widening.
   
   Doing `abs(-128::TINYLINT), abs(-32768::SMALLINT), abs(-2147483648::INT), 
abs(-9223372036854775808::BIGINT)` throws casting error. For example, 
`DataFusion error: Arrow error: Cast error: Can't cast value 128 to type Int8`
   
   



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