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/11/09 23:55:39 UTC

[GitHub] [spark] PerilousApricot commented on pull request #34505: [SPARK-37228][SQL][PYTHON] Implement DataFrame.mapInArrow in Python

PerilousApricot commented on pull request #34505:
URL: https://github.com/apache/spark/pull/34505#issuecomment-964650255


   Hi @HyukjinKwon - thanks for this PR! I had a question about the python-facing API. Is it possible to have something similar to how current python/pandas UDFs' withColumn() can tell spark which columns are necessary for the inputs and pass the remainder of the columns through to the resulting DF without round-tripping them through python? For example (open-coding this, might be missing some syntax):
   
   ```python
   
   df = spark.createDataFrame(
       [(1, "foo"), (2, None), (3, "bar"), (4, "bar")], "a int, b string")
   
   @udf(IntType())
   def squared(x):
       return x * x
   
   df = df.withColumn("squared", squared["a"]))
   ```
   
   Would only ser/de the "a" column through the function, but the remaining column "b" would be in the resulting dataframe. 


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