[
https://issues.apache.org/jira/browse/SPARK-60028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Yang Jie updated SPARK-60028:
-----------------------------
Description:
For a LIKE with a single pattern of the form 'prefix%suffix',
LikeSimplification rewrites `input LIKE pattern` into `OctetLength(input) >= n
AND StartsWith(input, prefix) AND EndsWith(input, suffix)`, copying `input`
three times without checking that it is deterministic. A nondeterministic input
is then evaluated once per copy, so the predicate can be true for a row where
no single value matches. The LikeAll/LikeAny cases already guard with
CollapseProject.isCheap.
Example: with a nondeterministic UDF `pick()` that returns 'ay' or 'bz' at
random, `SELECT pick() LIKE 'a%z' AS r FROM range(0, 1000, 1, 1)` returned 256
true rows in one run, where the correct count is 0.
Raised in https://github.com/apache/spark/pull/59209#discussion_r4199845624
> LikeSimplification duplicates a nondeterministic input of a single-pattern
> LIKE
> -------------------------------------------------------------------------------
>
> Key: SPARK-60028
> URL: https://issues.apache.org/jira/browse/SPARK-60028
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 5.0.0
> Reporter: Yang Jie
> Priority: Major
>
> For a LIKE with a single pattern of the form 'prefix%suffix',
> LikeSimplification rewrites `input LIKE pattern` into `OctetLength(input) >=
> n AND StartsWith(input, prefix) AND EndsWith(input, suffix)`, copying `input`
> three times without checking that it is deterministic. A nondeterministic
> input is then evaluated once per copy, so the predicate can be true for a row
> where no single value matches. The LikeAll/LikeAny cases already guard with
> CollapseProject.isCheap.
> Example: with a nondeterministic UDF `pick()` that returns 'ay' or 'bz' at
> random, `SELECT pick() LIKE 'a%z' AS r FROM range(0, 1000, 1, 1)` returned
> 256 true rows in one run, where the correct count is 0.
> Raised in https://github.com/apache/spark/pull/59209#discussion_r4199845624
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]