viirya opened a new pull request, #60276: URL: https://github.com/apache/spark/pull/60276
### What changes were proposed in this pull request? This PR backports #59551 (SPARK-60294) to branch-4.3. It disables `spark.sql.execution.arrow.pythonUDF.columnarInput.enabled` by default, and makes `ArrowEvalPythonExec.doExecute` check it too, through `supportsColumnar`, so that a child that also returns rows, such as the scan of the Arrow cache, returns rows when columnar input is disabled. It also adds the `reuseVectors` and `batchSize` options to the test source `ArrowBackedDataSourceV2`. The only conflict was in `docs/sql-migration-guide.md`: the entry goes into a new "Upgrading from Spark SQL 4.3.0 to 4.3.1" section instead of the 4.3-to-4.4 one. The "Since Spark 4.2.1" entry of the original change is left out, since 4.2.1 was released without it. ### Why are the changes needed? branch-4.3 still enables columnar input by default. With it enabled, the Arrow columnar path of `ColumnarArrowEvalPythonEvaluatorFactory` keeps the pass-through `ColumnVector`s of each input batch until the Python result of that batch comes back, which can be many batches later. A columnar reader may refill or release those vectors once it is asked for the next batch, so a scalar pandas or Arrow UDF on a column of such a source fails with `IndexOutOfBoundsException: index: 0, length: 1 (expected: range(0, 0))`, or pairs the pass-through values of a later batch with the UDF results of an earlier one. In 4.3 this also happens over the Arrow cache (`ArrowCachedBatchSerializer`), even with columnar input disabled, since `doExecute` took the columnar path whenever its child supported columnar. See #59551 for details. ### Does this PR introduce _any_ user-facing change? Yes. By default, Python UDFs on the columns of an Arrow-backed source no longer fail or return wrong results: Spark converts the batches to rows before the UDFs, as in Spark 4.1. Setting `spark.sql.execution.arrow.pythonUDF.columnarInput.enabled` to `true` enables columnar input again. The migration guide says so for 4.3.1. ### How was this patch tested? The tests of the original change: the new test in `ArrowColumnarPythonUDFSuite` and the new suite `ArrowCachedPythonUDFSuite` pass on branch-4.3 with JDK 17, as do `sql/scalastyle` and `sql/Test/scalastyle`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) This pull request and its description were written by Isaac. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
