feat: support factorial, pmod, and rint expressions#3586
feat: support factorial, pmod, and rint expressions#3586n0r0shi wants to merge 1 commit intoapache:mainfrom
Conversation
Register datafusion-spark's SparkFactorial, SparkPmod, and SparkRint UDFs and add serde mappings in mathExpressions.
andygrove
left a comment
There was a problem hiding this comment.
Serde wiring and UDF registrations look correct for all three expressions.
For the tests, the SQL file framework in spark/src/test/resources/sql-tests/expressions/math/ would be a natural home for these. There are already many math expression SQL files there.
On pmod, it might be worth testing the divide-by-zero case. Spark returns null for pmod(10, 0) with integer types and NaN for floating-point types. Floating-point inputs would also be good to cover since SparkPmod supports them.
On factorial, I like the coverage of negative and boundary values. One small thing: factorial(21) is the first value that returns null due to overflow protection. It could be worth adding that as a test case.
Summary
datafusion-sparkcrate (SparkFactorial,SparkPmod,SparkRint) to Cometjni_api.rsand add serde mappings viaCometScalarFunctioninQueryPlanSerde.scalaTest plan
CometMathExpressionSuite(factorial, pmod, rint) — all pass