andygrove commented on code in PR #16946: URL: https://github.com/apache/datafusion/pull/16946#discussion_r2291829074
########## datafusion/sqllogictest/test_files/spark/conditional/if.slt: ########## @@ -21,7 +21,135 @@ # For more information, please see: # https://github.com/apache/datafusion/issues/15914 -## Original Query: SELECT if(1 < 2, 'a', 'b'); -## PySpark 3.5.5 Result: {'(IF((1 < 2), a, b))': 'a', 'typeof((IF((1 < 2), a, b)))': 'string', 'typeof((1 < 2))': 'boolean', 'typeof(a)': 'string', 'typeof(b)': 'string'} -#query -#SELECT if((1 < 2)::boolean, 'a'::string, 'b'::string); +## Basic IF function tests + +# Test basic true condition +query T +SELECT if(true, 'yes', 'no'); Review Comment: Here is a test that demonstrates the issue: ```slt query II SELECT v, IF(v < 0, 10/0, 1) FROM (VALUES (1), (2)) t(v) ---- 1 1 2 1 ``` This fails with `DataFusion error: Arrow error: Divide by zero error`. The version of this test in `cast.slt` works correctly: ```slt query II SELECT v, CASE WHEN v < 0 THEN 10/0 ELSE 1 END FROM (VALUES (1), (2)) t(v) ---- 1 1 2 1 ``` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org