zhengruifeng commented on code in PR #37722:
URL: https://github.com/apache/spark/pull/37722#discussion_r959027515


##########
python/pyspark/sql/functions.py:
##########
@@ -149,7 +152,17 @@ def lit(col: Any) -> Column:
     +------+---+
     |     5|  0|
     +------+---+
+
+    Create a literal from a list.
+
+    >>> spark.range(1).select(F.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

Review Comment:
   so may looks like this:
   ```
       if isinstance(col, Column):
           return col
       elif isinstance(col, list):
           if any(isinstance(c, Column) for c in col):
               raise ValueError(...)
           return array(*[lit(item) for item in col])
       else:
           return _invoke_function("lit", col)
   ```



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