[ 
https://issues.apache.org/jira/browse/SPARK-62199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated SPARK-62199:
-----------------------------------
    Labels: SPIP pull-request-available  (was: SPIP)

> SPIP: Distinguish row-order-independent nondeterministic expressions in 
> Catalyst
> --------------------------------------------------------------------------------
>
>                 Key: SPARK-62199
>                 URL: https://issues.apache.org/jira/browse/SPARK-62199
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 5.0.0
>            Reporter: Saurabh Maurya
>            Priority: Major
>              Labels: SPIP, pull-request-available
>
> SPIP Design Doc: 
> [https://docs.google.com/document/d/1fgUl8U-RfUPdcvbcrc3C_gIoyN4GWQcIPjnD6uj-gOg/edit?tab=t.0#heading=h.4cp0crv5k1g7]
> Catalyst's Expression.deterministic conflates output repeatability with 
> independence from row order, row subset, and partition/task context 
> (SPARK-13473). As a result, Catalyst blocks unrelated filter pushdown, 
> dynamic partition pruning (DPP), semi/anti-join pushdown, DSv2 offset 
> pushdown, and single-reference project collapse across nondeterministic 
> projections.
> This proposal introduces an opt-in Expression.rowOrderIndependent property 
> (inheriting deterministic by default, so false for all existing 
> nondeterministic expressions and legacy .asNondeterministic() UDFs) that 
> separates per-row value-only nondeterminism from order-, subset-, and 
> context-dependent expressions while keeping deterministic = false and 
> stateful expressions unchanged.
> With this distinction, Catalyst can safely apply targeted optimizations — 
> such as pushing unrelated filters, dynamic partition pruning (DPP), 
> semi/anti-joins, and DSv2 offsets below row-order-independent projections 
> (and collapsing single-reference projections) — so expensive expressions like 
> random-IV aes_encrypt or external/AI RPC UDFs do not run on filtered-out rows.
> Proposed Delivery Split:
>  - Sub-task 1 (PR #1a, Catalyst-internal, no public API): Add 
> Expression.rowOrderIndependent (with cached ClassValue override check), 
> StaticInvoke.isRowOrderIndependent flag (with random-IV aes_encrypt as 
> proposed first in-tree caller via a 2-line follow-up), coordinated Catalyst 
> pushdowns/single-ref CollapseProject behind an internal kill-switch SQLConf, 
> and a standalone V2ExpressionBuilder isDeterministic guard.
>  - Sub-task 2 (PR #1b, SPIP-scoped public APIs): Add public 
> UserDefinedFunction opt-in API (naming open in [DISCUSS]), DSv2 
> ScalarFunction.isRowOrderIndependent(), PySpark Classic/Connect parity, and 
> Spark Connect proto field 8.
> Related JIRAs / PRs:
>  - SPARK-13473, SPARK-20246, SPARK-27969
>  - SPARK-59768 (PR #58867) & SPARK-60934 (PR #60178) — random-IV aes_encrypt
>  - SPARK-61672 & SPARK-61404 (PR #60311) — native AI functions
>  - SPARK-59726 — PolicyEnforcement security barriers (kept untouched)
>  - SPARK-61663 (PR #60469) — Expression.isTotal Catalyst property precedent



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to