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 2021/06/22 03:44:12 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #32955: [SPARK-35344][PYTHON] Support creating a Column of numpy literal value in pandas-on-Spark

HyukjinKwon commented on a change in pull request #32955:
URL: https://github.com/apache/spark/pull/32955#discussion_r655853638



##########
File path: python/pyspark/pandas/spark/functions.py
##########
@@ -32,6 +41,22 @@ def repeat(col: Column, n: Union[int, Column]) -> Column:
     return _call_udf(sc, "repeat", _to_java_column(col), n)
 
 
+def lit(literal: Any) -> Column:
+    """
+    Creates a Column of literal value.
+    """
+    if isinstance(literal, np.int64):

Review comment:
       @xinrong-databricks, I think we can just support this natively all across PySpark. Can you add an input converter here (https://github.com/apache/spark/blob/20750a3f9e13a2f02860859f87bbc38a18cba85e/python/pyspark/sql/types.py#L1608-L1622) and see if it works?
   
   Also, I think we can simplify it by `item()` (https://stackoverflow.com/a/11389998/2438480) with  `np.generic` type check (https://numpy.org/doc/stable/reference/arrays.scalars.html).
   
   cc @ueshin @itholic too




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

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