[
https://issues.apache.org/jira/browse/SPARK-59955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150203#comment-18150203
]
Yang Jie commented on SPARK-59955:
----------------------------------
Update: the first TODO can still happen. A definition that reads a lambda
variable has references, so it reaches this branch under an operator with one
child too, and a nondeterministic one is evaluated once per reference.
SPARK-62323 fixes that by keeping a `With` in a lambda function in place. After
it, the first TODO can become the invariant described above, and the second can
be removed as planned.
> Replace the stale TODOs in RewriteWithExpression's fallback for a definition
> no single child can evaluate
> ---------------------------------------------------------------------------------------------------------
>
> Key: SPARK-59955
> URL: https://issues.apache.org/jira/browse/SPARK-59955
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 5.0.0
> Reporter: Yang Jie
> Priority: Major
>
> When a common expression's definition reads columns from more than one child,
> as a join condition reading both sides does, RewriteWithExpression cannot
> pre-evaluate it in any child and inlines it into every reference. That branch
> carries two TODOs, and neither describes something that can still happen.
> 1. "things can go wrong if the common expression is nondeterministic". Only
> an operator with more than one child reaches the branch. Analysis rejects a
> nondeterministic join condition (INVALID_NON_DETERMINISTIC_EXPRESSIONS), a
> nondeterministic LATERAL join condition
> (LATERAL_JOIN_CONDITION_NON_DETERMINISTIC) and a nondeterministic MERGE
> condition. NearestByJoin allows a nondeterministic ranking expression, but
> RewriteNearestByJoin replaces the node in the "Finish Analysis" batch, before
> the "Rewrite With expression" batch runs.
> 2. "we should calculate the ref count and also inline the common expression
> if it's ref count is 1". SPARK-58818 added canSubstitute ahead of this
> branch, and it already inlines a definition referenced at most once.
> The first TODO should become a statement of the invariant, checked by an
> assertion when testing, and the second can be removed.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]