comphead commented on code in PR #24943: URL: https://github.com/apache/datafusion/pull/24943#discussion_r3935440218
########## datafusion/sqllogictest/test_files/spark/math/factorial.slt: ########## @@ -62,5 +62,35 @@ NULL NULL NULL -query error Error during planning: Failed to coerce arguments to satisfy a call to 'factorial' function -SELECT factorial(5::BIGINT); +# Spark declares factorial(INT) with ImplicitCastInputTypes, so every integer width is +# accepted; an untyped literal (Int64 in DataFusion) must work too. Values from Spark 4.2.0. +query IIIIII +SELECT factorial(5) AS i64_literal, + factorial(5::TINYINT) AS i8, + factorial(5::SMALLINT) AS i16, + factorial(5::BIGINT) AS i64, + factorial(arrow_cast(5, 'UInt64')) AS u64, + factorial(NULL) AS null_input; +---- +120 120 120 120 120 NULL + +query I +SELECT factorial(a) FROM VALUES (-1::BIGINT), (0::BIGINT), (20::BIGINT), (21::BIGINT), (NULL) AS t(a); +---- +NULL +1 +2432902008176640000 +NULL +NULL + +# DataFusion always fails at the Int32 cast here (this function does not consult +# datafusion.execution.enable_ansi_mode). Spark 4.2.0 raises CAST_OVERFLOW under +# ANSI mode but returns NULL when ANSI is off. +query error Can't cast value 5000000000 to type Int32 Review Comment: same -- 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]
