feat: support factorial, pmod, and rint expressions#3586
Open
n0r0shi wants to merge 1 commit intoapache:mainfrom
Open
feat: support factorial, pmod, and rint expressions#3586n0r0shi wants to merge 1 commit intoapache:mainfrom
n0r0shi wants to merge 1 commit intoapache:mainfrom
Conversation
Register datafusion-spark's SparkFactorial, SparkPmod, and SparkRint UDFs and add serde mappings in mathExpressions.
andygrove
reviewed
Feb 25, 2026
Member
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
datafusion-sparkcrate (SparkFactorial,SparkPmod,SparkRint) to Cometjni_api.rsand add serde mappings viaCometScalarFunctioninQueryPlanSerde.scalaTest plan
CometMathExpressionSuite(factorial, pmod, rint) — all pass