Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Branch 2.3 #21726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Branch 2.3 #21726
Changes from 1 commit
70be6034e138209632c462b80571befb22d43f5e403737c3d1c81c0cdbb1b39ab01ba7320ffb14f6a457bb26bdbfd66a3ba5a8a86bd83f7b129fd45f2c0585d24d131bae444903960fa0bd776575bb19accb0a598360da044095cbc7a0deaa1ee6f11d78f033e7269e373ac6423ba441a0d7949992447f285b841578607b1f180cd6eee54530242b6fe9cb4adfa4379a4eb1e42aa66eb56cfbd98fe20e1f12fa1326a8a67c8aa6fb88dd335232b9f84550673911b83db9ea2e866c19788cd6a96ee6e79786ca9151dd37ff404f7e28ff8e16bc5ce043ec25d5b083bd15bd306c265e61ea8e357a33ba8dbf3efbfa0663b61a9d078472c13ed2e1e27452a52d599f5c0bd9e1f7021b6de4693757180e794392049395c1c03d2f82c03c854b6c0b880db1e552b34b9f33fc9acd464da8c221d0d0a545761cece0fbecea44783523fcaf57026a12fd7aca328dea61c39dfa38c0bd70bfbcaf51630451365d733f5955a507cff2f1f10da6ca6483ce15651f36bdb428c9adba81e2030b7b8ccf93667fccc4a201a537a2bf1dabe0f2aabc320269eacfc15603a4dfd5712695908c6812995b79dfdf1bbd4f204c9857e24564019b6b99d5ba1c56b65bcb7bd130641132bec6c7fb1117fb96821be184d19b562d68eb64a5d914100c2f4ee78eb9a411c3e820096defd07ec75c4a10df0df45ddb235ec9e52a420f682f05d88abf7bb3adb530fe53b610e2f1fbfe50b661e7bc08509284d35eb2f3f78f60f87785a3a22fea4dc6719aba52f48889d78eab10f9323dc3a16cd9ac4c49b12414e4e31d598b77de4bef867d94888003f02f60df0a8ee5706dfb515cc93bc9eb7b373a886dc2e16ab6fd4a892a1708de228973e1895c95ed88f3e470b866593258d8efe183fed0060cded67093d2ae0b75e2cd1068c4aef48d624d0f30e354aeae7a06fc459b0f6f58bb6c22a9700cbfec43fe49a6c2b66289a3e1c0ab13a024a4dc24da2b37e76fe56266a1cc5f682e0c346e4e96f930aaa5a21800b8181945436f1d5e15829454d4548abf5868763e1da1a55de38470cacda2f65ebe6bf3257f1708ad3255a5a7d378ed4261049d63e54b8dbfcc50cdb41d687d978928de33a4b6f3a1e9640db538b26e1f5e00f534d38ff4b973c0af791cba050bc7ee75e5cc5f664c72b44df06b472eb97c19542f5307499e86457a132429259cf375fb3726daf9a2b0adae352ae31b4767be70e2File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
pandas_udfwith keyw……ord args ## What changes were proposed in this pull request? Add documentation about the limitations of `pandas_udf` with keyword arguments and related concepts, like `functools.partial` fn objects. NOTE: intermediate commits on this PR show some of the steps that can be taken to fix some (but not all) of these pain points. ### Survey of problems we face today: (Initialize) Note: python 3.6 and spark 2.4snapshot. ``` from pyspark.sql import SparkSession import inspect, functools from pyspark.sql.functions import pandas_udf, PandasUDFType, col, lit, udf spark = SparkSession.builder.getOrCreate() print(spark.version) df = spark.range(1,6).withColumn('b', col('id') * 2) def ok(a,b): return a+b ``` Using a keyword argument at the call site `b=...` (and yes, *full* stack trace below, haha): ``` ---> 14 df.withColumn('ok', pandas_udf(f=ok, returnType='bigint')('id', b='id')).show() # no kwargs TypeError: wrapper() got an unexpected keyword argument 'b' ``` Using partial with a keyword argument where the kw-arg is the first argument of the fn: *(Aside: kind of interesting that lines 15,16 work great and then 17 explodes)* ``` --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-9-e9f31b8799c1> in <module>() 15 df.withColumn('ok', pandas_udf(f=functools.partial(ok, 7), returnType='bigint')('id')).show() 16 df.withColumn('ok', pandas_udf(f=functools.partial(ok, b=7), returnType='bigint')('id')).show() ---> 17 df.withColumn('ok', pandas_udf(f=functools.partial(ok, a=7), returnType='bigint')('id')).show() /Users/stu/ZZ/spark/python/pyspark/sql/functions.py in pandas_udf(f, returnType, functionType) 2378 return functools.partial(_create_udf, returnType=return_type, evalType=eval_type) 2379 else: -> 2380 return _create_udf(f=f, returnType=return_type, evalType=eval_type) 2381 2382 /Users/stu/ZZ/spark/python/pyspark/sql/udf.py in _create_udf(f, returnType, evalType) 54 argspec.varargs is None: 55 raise ValueError( ---> 56 "Invalid function: 0-arg pandas_udfs are not supported. " 57 "Instead, create a 1-arg pandas_udf and ignore the arg in your function." 58 ) ValueError: Invalid function: 0-arg pandas_udfs are not supported. Instead, create a 1-arg pandas_udf and ignore the arg in your function. ``` Author: Michael (Stu) Stewart <[email protected]> Closes #20900 from mstewart141/udfkw2. (cherry picked from commit 087fb31) Signed-off-by: hyukjinkwon <[email protected]> Signed-off-by: hyukjinkwon <[email protected]>Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing