saurabh-net opened a new pull request, #60778:
URL: https://github.com/apache/spark/pull/60778

   > **Draft / WIP Prototype — waiting on feedback on the [SPIP design 
doc](https://docs.google.com/document/d/1fgUl8U-RfUPdcvbcrc3C_gIoyN4GWQcIPjnD6uj-gOg/edit),
 [SPARK-62199](https://issues.apache.org/jira/browse/SPARK-62199), and 
Catalyst-internal PR #60776.**
   >
   > This PR is stacked on top of #60776 so reviewers can inspect the full 
end-to-end public API surface (Scala/Java/PySpark UDFs, DSv2 `ScalarFunction`, 
and Spark Connect) while reviewing #60776. To view **only** the public API diff 
without #60776, inspect the second commit directly: 
[`c6208de1`](https://github.com/saurabh-net/spark/commit/c6208de1ea13a382fad81e9f56576bdc91bb057d).
   
   ### What changes were proposed in this pull request?
   
   This is the SPIP-scoped public API follow-up (PR #1b) for 
[SPARK-62199](https://issues.apache.org/jira/browse/SPARK-62199) ([SPIP design 
doc](https://docs.google.com/document/d/1fgUl8U-RfUPdcvbcrc3C_gIoyN4GWQcIPjnD6uj-gOg/edit)),
 stacked on the Catalyst-internal foundation in #60776.
   
   - **`sql/api` & `common/utils`:** Add `@since 5.0.0` 
`UserDefinedFunction.rowOrderIndependent` (inheriting `deterministic`) and an 
opt-in builder method (prototype name 
`asRowOrderIndependentNondeterministic()`, naming open for `dev@spark` SPIP 
discussion) with binary-compatible default methods, chaining reset fixes, and 
`UNSUPPORTED_FEATURE.ROW_ORDER_INDEPENDENT_AGGREGATOR` rejecting 
`UserDefinedAggregator`.
   - **`sql/catalyst` & `sql/core`:** Add `@since 5.0.0` 
`ScalarFunction.isRowOrderIndependent()` (defaulting to `isDeterministic()`, 
keeping `BoundFunction` untouched), forward `udfRowOrderIndependent` through 
`ScalaUDF`, `PythonUDF`, `ApplyFunctionExpression`, `Invoke`/`StaticInvoke`, 
and `ExtractPythonUDFFromLambda`, and reject all 9 grouped/window aggregate 
`PythonEvalType`s.
   - **`python/pyspark`:** Expose the Python UDF opt-in API (including scalar 
`@pandas_udf`), invalidate transpiled caches on builder mutation, preserve 
`bufferSchema`, and reject aggregate UDFs.
   - **`sql/connect`:** Add `optional bool row_order_independent = 8` to 
`CommonInlineUserDefinedFunction` with sparse encoding (omitted when default), 
planner forwarding, and UDAF rejection.
   
   ### Why are the changes needed?
   
   #60776 introduces the internal Catalyst property and pushdown rules. This 
follow-up exposes that opt-in capability cleanly to Scala, Java, PySpark, 
DataSource V2 `ScalarFunction`, and Spark Connect users so expensive 
row-order-independent nondeterministic UDFs (such as external/AI RPC UDFs in 
[SPARK-61672](https://issues.apache.org/jira/browse/SPARK-61672)) can benefit 
from unrelated filter pushdown, partition pruning, DPP, and semi/anti-join 
pushdown without falsely marking themselves deterministic.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes (opt-in only; legacy `.asNondeterministic()` UDFs and existing DSv2 
functions keep `rowOrderIndependent = false`):
   - Adds `@since 5.0.0` opt-in `rowOrderIndependent` APIs on 
`UserDefinedFunction` (Scala/Java/PySpark) and DSv2 `ScalarFunction`.
   - Adds optional Spark Connect protobuf field 
`CommonInlineUserDefinedFunction.row_order_independent = 8`.
   - Adds error condition 
`UNSUPPORTED_FEATURE.ROW_ORDER_INDEPENDENT_AGGREGATOR` when opting an 
aggregator/UDAF into row-order-independent nondeterminism.
   
   ### How was this patch tested?
   
   - Extended `UDFSuite`, `DataSourceV2FunctionSuite`, 
`ExtractPythonUDFsSuite`, `PythonUDFSuite`, `BatchEvalPythonExecSuite`, 
`SparkThrowableSuite`, Spark Connect planner/proto wire-compatibility suites, 
and PySpark Classic (`test_udf.py`) + Connect (`test_parity_udf.py`) parity 
suites.
   - Verified clean compile, `scalastyle:check`, `SparkThrowableSuite`, 
`UDFSuite`, `DataSourceV2FunctionSuite`, and `ExtractPythonUDFsSuite` (150/150 
passed) after rebasing onto `master` (`634e3261`) + #60776.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Yes (all changes reviewed, tested, and verified by the author).
   


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

Reply via email to