[
https://issues.apache.org/jira/browse/CALCITE-6990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18041929#comment-18041929
]
Mihai Budiu commented on CALCITE-6990:
--------------------------------------
This is a very tricky question. There are two things that matter about rand():
the number of times it is called, and the order the calls are evaluated.
Clearly, if the plan produces a different number of calls to rand(), it's wrong
(unless it removes provably dead calls). The one about the order is much
trickier: if rand() uses a standard seed-based random number generator, then
each rand() call has a side-effect influencing the next call. So the rand()
calls have to obey the dependence rules imposed by the SQL standard. I wonder
if this could even make rewrites such as query decorrelation illegal?
> Optimization passes should be checked for handling DynamicParameter
> -------------------------------------------------------------------
>
> Key: CALCITE-6990
> URL: https://issues.apache.org/jira/browse/CALCITE-6990
> Project: Calcite
> Issue Type: Task
> Components: core
> Affects Versions: 1.39.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> Several PRs have fixed optimization passes which are wrong when queries can
> contain dynamic parameters. Perhaps all of the passes should be audited with
> this case in mind.
> See [CALCITE-6647] and [CALCITE-6983]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)