CODERNSINGH commented on code in PR #60222:
URL: https://github.com/apache/spark/pull/60222#discussion_r4525214358


##########
python/pyspark/sql/tests/test_column.py:
##########
@@ -123,6 +123,14 @@ def test_column_operators(self):
             ValueError, "Cannot apply 'in' operator against a column", lambda: 
1 in cs
         )
 
+    def test_startswith_endswith_with_none(self):
+        # SPARK-48995: startswith/endswith with None should return null 
instead of failing
+        df = self.spark.createDataFrame([("abc",), (None,)], "s string")
+        for name in ["startswith", "endswith"]:
+            with self.subTest(name=name):
+                result = df.select(getattr(df.s, 
name)(None).alias("r")).collect()
+                self.assertEqual(result, [Row(r=None), Row(r=None)])

Review Comment:
   Added `test_startswith_endswith_with_non_string_literal`, which checks 
`startswith(1)`/`endswith(1)` in both classic and Spark Connect. On master this 
fails deterministically (`Method startsWith([class java.lang.Integer]) does not 
exist`), so reverting the conversion is always caught.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to