itholic commented on code in PR #39387:
URL: https://github.com/apache/spark/pull/39387#discussion_r1061376821


##########
python/pyspark/sql/tests/test_functions.py:
##########
@@ -1030,9 +1031,13 @@ def test_lit_list(self):
             self.assertEqual(actual, expected)
 
         df = self.spark.range(10)
-        with self.assertRaisesRegex(ValueError, "lit does not allow a column 
in a list"):
+        with self.assertRaises(PySparkException) as pe:
             lit([df.id, df.id])
 
+        self.check_error(
+            exception=pe, error_class="COLUMN_IN_LIST", 
message_parameters={"funcName": "lit"}
+        )

Review Comment:
   ditto.
   
   Will migrate all error tests into error class tests.



##########
python/pyspark/sql/functions.py:
##########
@@ -172,7 +173,9 @@ def lit(col: Any) -> Column:
         return col
     elif isinstance(col, list):
         if any(isinstance(c, Column) for c in col):
-            raise ValueError("lit does not allow a column in a list")
+            raise PySparkException(
+                error_class="COLUMN_IN_LIST", message_parameters={"funcName": 
"lit"}
+            )

Review Comment:
   ditto.
   
   Will migrate all errors in large batches as follow-ups
   
   I believe it would be a big task, so I will create several sub-tasks under 
[umbrella JIRA](https://issues.apache.org/jira/browse/SPARK-41597).



-- 
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