Skip to content

[AURON #2572] Support array_contains natively - #2573

Open
Sigma-Ma wants to merge 5 commits into
apache:masterfrom
Sigma-Ma:Auron-2572-support-array-contains-natively
Open

Sigma-Ma wants to merge 5 commits into
apache:masterfrom
Sigma-Ma:Auron-2572-support-array-contains-natively

Conversation

@Sigma-Ma

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #2572

Rationale for this change

array_contains currently falls back to Spark execution.

What changes are included in this PR?

Add native array_contains support for supported atomic element types. Match Spark's null, NaN, and signed-zero semantics, and reuse scalar arguments without expanding constant arrays for each input row.

Keep unsupported element types on Spark execution and test both fallback configurations.

Are there any user-facing changes?

array_contains can run natively for supported atomic element types.

How was this patch tested?

  • cargo test -p datafusion-ext-functions --locked.
  • ./build/mvn -Ppre -Pspark-3.5 -Pscala-2.12 -pl spark-extension-shims-spark -DskipBuildNative -Dsuites=org.apache.auron.AuronFunctionSuite test.
  • ./dev/reformat.

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

  • Yes
  • No

Generated-by: OpenAI Codex (GPT-6)

}

// Spark treats all NaNs as equal and -0.0 as equal to 0.0.
macro_rules! float_eq {

@robreeves robreeves Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2545 also adds float equality logic in spark_float_cmp. The comparison logic could be added to native-engine/datafusion-ext-commons/src and shared across both cases since the float checking is not scoped to just this function. Here the array contains check could check if spark_float_cmp returns Ordering::Equal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I've added spark_float_cmp to datafusion-ext-commons and reused it in array_contains, with Float/Double tests for NaN, signed zero, and ordering.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@Sigma-Ma
Sigma-Ma requested a review from robreeves October 15, 2026 03:48
try {
exec.setTagValue(convertibleTag, true)
convert(exec)
Shims.get.setLogicalLink(convert(exec), exec)

@robreeves robreeves Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #2492 it also solves this issue in a different way. The description discusses why tryConvert was not chosen. Should we remove this and let it be fixed in #2492? FYI @weiqingy (author of other PR).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I've removed the tryConvert change and the logical-link assertion, leaving that fix to #2492. The fallback test now executes each DataFrame once while still checking both fallback modes and the expected rows~

@slfan1989 slfan1989 self-assigned this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support array_contains natively

3 participants