[
https://issues.apache.org/jira/browse/SPARK-62199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Saurabh Maurya updated SPARK-62199:
-----------------------------------
Description:
SPIP Design Doc:
https://docs.google.com/document/d/1fgUl8U-RfUPdcvbcrc3C_gIoyN4GWQcIPjnD6uj-gOg/edit
PR #1a (Catalyst-internal, Ready for Review):
https://github.com/apache/spark/pull/60776
PR #1b (Public APIs, WIP Draft stacked on #60776):
https://github.com/apache/spark/pull/60778
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) — while preserving
deterministic == false invariants (no folding/CSE, 1x multi-ref CTE sharing,
ANSI error ordering, and limit barriers).
Scope & Sequencing:
- Sub-task 1 (PR #1a, Catalyst-internal,
https://github.com/apache/spark/pull/60776): Add Expression.rowOrderIndependent
and StaticInvoke.isRowOrderIndependent, and enable disjoint pushdowns (Project,
grouped Aggregate, semi/anti-join, DSv2 offset) and single-ref CollapseProject
behind an internal kill-switch SQLConf. Random-IV aes_encrypt is the proposed
first in-tree caller (2-line follow-up).
- Sub-task 2 (PR #1b, SPIP-scoped public APIs, WIP Draft
https://github.com/apache/spark/pull/60778): Add public UserDefinedFunction
opt-in API (naming open for dev@spark discussion), DSv2
ScalarFunction.isRowOrderIndependent(), PySpark Classic/Connect parity
(including BatchEvalPython/ArrowEvalPython pushdown), and Spark Connect
CommonInlineUserDefinedFunction.row_order_independent (optional bool, field 8).
- Follow-ups: Random-IV aes_encrypt opt-in (SPARK-59768 / PR #58867,
SPARK-60934 / PR #60178), build-side DPP/cache lineage relaxation, and
Language-Agnostic UDFs (SPARK-55278).
was:
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
> 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
> PR #1a (Catalyst-internal, Ready for Review):
> https://github.com/apache/spark/pull/60776
> PR #1b (Public APIs, WIP Draft stacked on #60776):
> https://github.com/apache/spark/pull/60778
> 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) — while preserving deterministic == false invariants (no
> folding/CSE, 1x multi-ref CTE sharing, ANSI error ordering, and limit
> barriers).
> Scope & Sequencing:
> - Sub-task 1 (PR #1a, Catalyst-internal,
> https://github.com/apache/spark/pull/60776): Add
> Expression.rowOrderIndependent and StaticInvoke.isRowOrderIndependent, and
> enable disjoint pushdowns (Project, grouped Aggregate, semi/anti-join, DSv2
> offset) and single-ref CollapseProject behind an internal kill-switch
> SQLConf. Random-IV aes_encrypt is the proposed first in-tree caller (2-line
> follow-up).
> - Sub-task 2 (PR #1b, SPIP-scoped public APIs, WIP Draft
> https://github.com/apache/spark/pull/60778): Add public UserDefinedFunction
> opt-in API (naming open for dev@spark discussion), DSv2
> ScalarFunction.isRowOrderIndependent(), PySpark Classic/Connect parity
> (including BatchEvalPython/ArrowEvalPython pushdown), and Spark Connect
> CommonInlineUserDefinedFunction.row_order_independent (optional bool, field
> 8).
> - Follow-ups: Random-IV aes_encrypt opt-in (SPARK-59768 / PR #58867,
> SPARK-60934 / PR #60178), build-side DPP/cache lineage relaxation, and
> Language-Agnostic UDFs (SPARK-55278).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]