Open
Conversation
Expose the upstream DataFusion `contains(string, search_str)` function which returns true if search_str is found within string (case-sensitive). Note: the other functions from apache#1450 (instr, position, substring_index) already exist — instr and position are aliases for strpos, and substring_index is exposed as substr_index. Closes apache#1450 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes #1450 by exposing DataFusion’s upstream contains string scalar function through both the Rust (PyO3) bindings and the public Python datafusion.functions API, with a corresponding unit test to validate behavior.
Changes:
- Added a PyO3 wrapper for
containsin the Rust core bindings and registered it in the Python module init. - Exposed
containsinpython/datafusion/functions.py(including__all__) with a user-facing docstring. - Added a unit test case covering
functions.containson string input.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/core/src/functions.rs |
Adds the contains binding via expr_fn! and registers it in init_module. |
python/datafusion/functions.py |
Exposes contains in the public Python API and exports it via __all__. |
python/tests/test_functions.py |
Adds an assertion verifying contains produces the expected boolean array results. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Which issue does this PR close?
Closes #1450
Rationale for this change
This function was not exposed, but exists upstream.
What changes are included in this PR?
Expose function on rust and python APIs.
Add unit test.
Are there any user-facing changes?
Addition only.