GitHub user JoshRosen opened a pull request: https://github.com/apache/spark/pull/17927
[SPARK-20685] Fix BatchPythonEvaluation bug in case of single UDF w/ repeated arg. ## What changes were proposed in this pull request? There's a latent corner-case bug in PySpark UDF evaluation where executing a `BatchPythonEvaluation` with a single multi-argument UDF where _at least one argument value is repeated_ will crash at execution with a confusing error. This problem was introduced in #12057: there code there has a fast path for handling a "batch UDF evaluation consisting of a single Python UDF", but that branch incorrectly assumes that a single UDF won't have repeated arguments and therefore skips the code for unpacking arguments from the input row (whose schema may not necessarily match the UDF inputs due to de-duplication of repeated arguments which occurred in the JVM before sending UDF inputs to Python). This fix here is simply to remove this special-casing: it turns out that the code in the "multiple UDFs" branch just so happens to work for the single-UDF case because Python treats `(x)` as equivalent to `x`, not as a single-argument tuple. ## How was this patch tested? New regression test in `pyspark.python.sql.tests` module (tested and confirmed that it fails before my fix). You can merge this pull request into a Git repository by running: $ git pull https://github.com/JoshRosen/spark SPARK-20685 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/17927.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #17927 ---- commit 6912cb205125b0e8e70a440d4b73252551b9c35d Author: Josh Rosen <joshro...@databricks.com> Date: 2017-05-09T21:53:08Z Add (failing) regression test. commit 17e69b5c10eeb9a6138a50985ed891ebae398619 Author: Josh Rosen <joshro...@databricks.com> Date: 2017-05-09T22:15:17Z Fix SPARK-20685 ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org