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


##########
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:
   qq: Maybe seems like the Scala side even doesn't allow for the single 
`Column` case ??
   
   ```scala
   scala> df.select(lit(df.id)).show()
   <console>:24: error: value id in class Dataset cannot be accessed in 
org.apache.spark.sql.Dataset[Long]
          df.select(lit(df.id)).show()
   ```
   
   which is allowed in Python side:
   
   ```python
   >>> df.select(F.lit(df.id)).show()
   +---+
   | id|
   +---+
   |  0|
   |  1|
   |  2|
   |  3|
   |  4|
   |  5|
   |  6|
   |  7|
   |  8|
   |  9|
   +---+
   ```



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