Skip to content

[GLUTEN-12157][VL] Register sin, tan, tanh, radians, ln in Velox sparksql function registry#12158

Open
brijrajk wants to merge 1 commit into
apache:mainfrom
brijrajk:feat/register-sparksql-math-functions
Open

[GLUTEN-12157][VL] Register sin, tan, tanh, radians, ln in Velox sparksql function registry#12158
brijrajk wants to merge 1 commit into
apache:mainfrom
brijrajk:feat/register-sparksql-math-functions

Conversation

@brijrajk
Copy link
Copy Markdown

What changes are proposed in this pull request?

Five math scalar functions (sin, tan, tanh, radians, ln) are mapped in
ExpressionMappings.scala to their Substrait counterparts but were missing from
Gluten's Velox C++ function registry (RegistrationAllFunctions.cc). Queries using
these functions silently fell back to vanilla Spark instead of running natively in Velox.

This PR registers them in registerFunctionOverwrite() using the existing Velox prestosql
implementations from velox/functions/prestosql/Arithmetic.h, which match Spark's expected
semantics for these functions.

Also fixes a leftover from PR #11756 (RAS removal): MathFunctionsValidateSuite and
ScalarFunctionsValidateSuite were left as abstract class after their only concrete
subclasses were deleted, causing all tests in those suites to silently not run. Both are
promoted to class here, consistent with the fix already applied to
DateFunctionsValidateSuite in that same PR.

Fixes #12157

How was this patch tested?

Added tests in MathFunctionsValidateSuite for each of the five functions using
runQueryAndCompare with checkGlutenPlan[ProjectExecTransformer] to verify native
execution in Velox without fallback.

MathFunctionsValidateSuite now explicitly disables ANSI mode (enabled by default in
Spark 4), which wraps arithmetic expressions in ANSI check nodes and shifts the top-level
plan node away from ProjectExecTransformer. ANSI-specific behavior is covered by the
existing MathFunctionsValidateSuiteAnsiOn.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude (Anthropic)

@github-actions github-actions Bot added the VELOX label May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Register missing math scalar functions in Velox sparksql registry (sin, tan, tanh, radians, ln)

1 participant