Conversation
…che#1449) Expose four conditional functions from upstream DataFusion that were not yet available in the Python bindings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover multiple data types (integers, strings), null handling (all-null, partial-null), multiple arguments, and ifnull/nvl equivalence. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Exposes missing conditional scalar functions in datafusion-python to close #1449, adding Python wrappers/bindings and unit tests.
Changes:
- Add Python API functions:
greatest,least,nvl2, andifnull(alias fornvl). - Add Rust PyO3 bindings for
greatest,least(variadic) andnvl2. - Add unit tests covering numeric/string behavior and null handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/datafusion/functions.py | Adds new public Python wrappers and updates exports (__all__). |
| crates/core/src/functions.rs | Exposes the corresponding DataFusion functions to Python via PyO3 wrappers. |
| python/tests/test_functions.py | Adds unit tests validating the new functions’ behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert result.column(0).to_pylist() == ["banana", "cherry"] | ||
|
|
||
|
|
||
| def test_least(df): |
There was a problem hiding this comment.
df fixture is accepted but never used in this test. Because pytest will still construct the fixture, this adds unnecessary setup cost and can slow the suite. Either remove the df parameter or refactor the test to reuse the provided fixture/context instead of creating a new SessionContext.
| def test_least(df): | |
| def test_least(): |
| def test_nvl2(df): | ||
| ctx = SessionContext() | ||
| batch = pa.RecordBatch.from_arrays( | ||
| [ |
There was a problem hiding this comment.
df fixture is accepted but never used in this test. Because pytest will still construct the fixture, this adds unnecessary setup cost and can slow the suite. Either remove the df parameter or refactor the test to reuse the provided fixture/context instead of creating a new SessionContext.
| def test_ifnull(df): | ||
| ctx = SessionContext() | ||
| batch = pa.RecordBatch.from_arrays( |
There was a problem hiding this comment.
df fixture is accepted but never used in this test. Because pytest will still construct the fixture, this adds unnecessary setup cost and can slow the suite. Either remove the df parameter or refactor the test to reuse the provided fixture/context instead of creating a new SessionContext.
| ) | ||
|
|
||
|
|
||
| def test_greatest(df): |
There was a problem hiding this comment.
df fixture is accepted but never used in this test. Because pytest will still construct the fixture, this adds unnecessary setup cost and can slow the suite. Either remove the df parameter or refactor the test to reuse the provided fixture/context instead of creating a new SessionContext.
| def test_greatest(df): | |
| def test_greatest(): |
Which issue does this PR close?
Closes #1449
Rationale for this change
There are a few methods missing from the Python library, so this exposes them.
What changes are included in this PR?
Exposes python functions.
Adds unit tests.
Are there any user-facing changes?
Addition only.