You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/12/13 08:36:53 UTC

[GitHub] [spark] zhengruifeng commented on a diff in pull request #39047: [SPARK-41506][CONNECT][PYTHON] Refactor LiteralExpression to support DataType

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


##########
python/pyspark/sql/connect/functions.py:
##########
@@ -92,8 +92,19 @@ def col(col: str) -> Column:
 def lit(col: Any) -> Column:

Review Comment:
   actually, PySpark's [`lit` function](https://github.com/apache/spark/blob/master/python/pyspark/sql/functions.py#L168-L179) do not support `tuple` and `dict`, and it just start to support `list` since 3.4.0.
   
   ```
   In [6]: from pyspark.sql import functions as SF
   
   In [7]: SF.lit({1 : 2})
   ---------------------------------------------------------------------------
   Py4JJavaError                             Traceback (most recent call last)
   Cell In[7], line 1
   ----> 1 SF.lit({1 : 2})
   ...
   
   Py4JJavaError: An error occurred while calling z:org.apache.spark.sql.functions.lit.
   : org.apache.spark.SparkRuntimeException: [UNSUPPORTED_FEATURE.LITERAL_TYPE] The feature is not supported: Literal for '{1=2}' of class java.util.HashMap.
           at 
   ...
   
   In [8]: SF.lit(("a", "b"))
   ---------------------------------------------------------------------------
   Py4JJavaError                             Traceback (most recent call last)
   Cell In[8], line 1
   ----> 1 SF.lit(("a", "b"))
   ...
   
   Py4JJavaError: An error occurred while calling z:org.apache.spark.sql.functions.lit.
   : org.apache.spark.SparkRuntimeException: [UNSUPPORTED_FEATURE.LITERAL_TYPE] The feature is not supported: Literal for '[a, b]' of class java.util.ArrayList.
   
   ...
   
   In [9]: SF.lit(["a", "b"])
   Out[9]: Column<'array(a, b)'>
   ```
   
   I'm thinking of removing `struct` and `map` here.
   
   
   
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org