Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/pyspark/sql/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,14 @@ def test_try_make_interval(self):
actual = df.select(F.isnull(F.try_make_interval("num")))
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.

actual = df.select(F.try_mod("a", "b").alias("r"))
assertDataFrameEqual([Row(r=0), Row(r=1), Row(r=None)], actual)

actual = df.select(F.try_mod(F.col("a"), F.lit(2)).alias("r"))
assertDataFrameEqual([Row(r=0), Row(r=1), Row(r=0)], actual)

def test_octet_length_function(self):
# SPARK-36751: add octet length api for python
df = self.spark.createDataFrame([("cat",), ("\U0001f408",)], ["cat"])
Expand Down