HyukjinKwon commented on code in PR #37722:
URL: https://github.com/apache/spark/pull/37722#discussion_r959081857
##########
python/pyspark/sql/functions.py:
##########
@@ -155,15 +155,21 @@ def lit(col: Any) -> Column:
Create a literal from a list.
- >>> spark.range(1).select(F.lit([1, 2, 3])).show()
+ >>> spark.range(1).select(lit([1, 2, 3])).show()
+--------------+
|array(1, 2, 3)|
+--------------+
| [1, 2, 3]|
+--------------+
"""
- col = array(*[lit(item) for item in col]) if isinstance(col, list) else col
- return col if isinstance(col, Column) else _invoke_function("lit", col)
+ if isinstance(col, Column):
+ return col
+ elif isinstance(col, list):
+ if any(isinstance(c, Column) for c in col):
+ raise ValueError("lit does not allow for list of Columns")
Review Comment:
```suggestion
raise ValueError("lit does not allow a column in a list")
```
--
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]