-
Notifications
You must be signed in to change notification settings - Fork 151
Add missing conditional functions #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1435,3 +1435,165 @@ def test_coalesce(df): | |||||
| assert result.column(0) == pa.array( | ||||||
| ["Hello", "fallback", "!"], type=pa.string_view() | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def test_greatest(df): | ||||||
| ctx = SessionContext() | ||||||
| batch = pa.RecordBatch.from_arrays( | ||||||
| [ | ||||||
| pa.array([1, 5, None]), | ||||||
| pa.array([3, 2, None]), | ||||||
| pa.array([2, 8, None]), | ||||||
| ], | ||||||
| names=["a", "b", "c"], | ||||||
| ) | ||||||
| df_test = ctx.create_dataframe([[batch]]) | ||||||
|
|
||||||
| # Test greatest with two columns | ||||||
| result = df_test.select( | ||||||
| f.greatest(column("a"), column("b")).alias("greatest_ab") | ||||||
| ).collect()[0] | ||||||
| assert result.column(0) == pa.array([3, 5, None], type=pa.int64()) | ||||||
|
|
||||||
| # Test greatest with three columns | ||||||
| result = df_test.select( | ||||||
| f.greatest(column("a"), column("b"), column("c")).alias("greatest_abc") | ||||||
| ).collect()[0] | ||||||
| assert result.column(0) == pa.array([3, 8, None], type=pa.int64()) | ||||||
|
|
||||||
| # Test greatest with nulls mixed in (partial nulls) | ||||||
| batch2 = pa.RecordBatch.from_arrays( | ||||||
| [ | ||||||
| pa.array([None, 10]), | ||||||
| pa.array([5, None]), | ||||||
| ], | ||||||
| names=["x", "y"], | ||||||
| ) | ||||||
| df_test2 = ctx.create_dataframe([[batch2]]) | ||||||
| result = df_test2.select(f.greatest(column("x"), column("y")).alias("g")).collect()[ | ||||||
| 0 | ||||||
| ] | ||||||
| assert result.column(0) == pa.array([5, 10], type=pa.int64()) | ||||||
|
|
||||||
| # Test greatest with string columns | ||||||
| batch3 = pa.RecordBatch.from_arrays( | ||||||
| [ | ||||||
| pa.array(["apple", "cherry"]), | ||||||
| pa.array(["banana", "apricot"]), | ||||||
| ], | ||||||
| names=["s1", "s2"], | ||||||
| ) | ||||||
| df_test3 = ctx.create_dataframe([[batch3]]) | ||||||
| result = df_test3.select( | ||||||
| f.greatest(column("s1"), column("s2")).alias("g") | ||||||
| ).collect()[0] | ||||||
| assert result.column(0).to_pylist() == ["banana", "cherry"] | ||||||
|
|
||||||
|
|
||||||
| def test_least(df): | ||||||
|
||||||
| def test_least(df): | |
| def test_least(): |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dffixture 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 thedfparameter or refactor the test to reuse the provided fixture/context instead of creating a newSessionContext.