Skip to content

[SPARK-54476][PYTHON][TEST] Add coverage test for try_mod#55964

Open
fallintoplace wants to merge 1 commit into
apache:masterfrom
fallintoplace:SPARK-54476-try-mod-test
Open

[SPARK-54476][PYTHON][TEST] Add coverage test for try_mod#55964
fallintoplace wants to merge 1 commit into
apache:masterfrom
fallintoplace:SPARK-54476-try-mod-test

Conversation

@fallintoplace
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR adds PySpark SQL function coverage for try_mod in test_functions.py. The test covers column-name operands, Column plus literal operands, and division by zero returning null.

Why are the changes needed?

SPARK-54476 tracks adding try_mod coverage in test_functions.py. This adds direct coverage for the PySpark function wrapper.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

env JAVA_HOME=/opt/homebrew/opt/openjdk PATH=/opt/homebrew/opt/openjdk/bin:$PATH ./build/mvn -DskipTests package
env JAVA_HOME=/opt/homebrew/opt/openjdk PATH=/opt/homebrew/opt/openjdk/bin:$PATH OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES python3 python/run-tests.py --testnames "pyspark.sql.tests.test_functions FunctionsTests.test_try_mod_function" --python-executables python3
git diff --check
python3 -m py_compile python/pyspark/sql/tests/test_functions.py

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

Generated-by: GPT-5.5 xhigh

assertDataFrameEqual([Row(True)], actual)

def test_try_mod_function(self):
df = self.spark.createDataFrame([(6000, 15), (3, 2), (1234, 0)], ["a", "b"])
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.

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.

Good point @zhengruifeng, thanks. I missed that the main try_mod behavior is already covered by the doctest. The only additional coverage here is the Column + literal path, which is probably too small to justify a separate test. I will close this PR unless you think explicit coverage in test_functions.py is still useful for SPARK-54476.

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.

2 participants