Skip to content

Conversation

@Shekharrajak
Copy link

Which issue does this PR close?

Closes #2972.

Rationale for this change

The contains expression shows poor performance in Comet (0.2X vs Spark) because DataFusion's make_scalar_function wrapper expands scalar patterns to arrays, bypassing arrow-rs's optimized scalar path.

What changes are included in this PR?

  • Add SparkContains UDF with optimized scalar pattern handling using memchr::memmem::Finder for SIMD-accelerated substring search
  • Register the function in comet_scalar_funcs.rs to override DataFusion's built-in contains
  • Add contains to CometStringExpressionBenchmark
  • Enhance contains test in CometExpressionSuite

How are these changes tested?

  • 4 new unit tests in contains.rs (array-scalar, scalar-scalar, null handling, empty pattern)
  • Enhanced integration test in CometExpressionSuite.scala
  • All 122 spark-expr tests pass

@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.58%. Comparing base (f09f8af) to head (54dc054).
⚠️ Report is 803 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2991      +/-   ##
============================================
+ Coverage     56.12%   59.58%   +3.46%     
- Complexity      976     1377     +401     
============================================
  Files           119      167      +48     
  Lines         11743    15493    +3750     
  Branches       2251     2569     +318     
============================================
+ Hits           6591     9232    +2641     
- Misses         4012     4962     +950     
- Partials       1140     1299     +159     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve performance of contains expression

2 participants