[
https://issues.apache.org/jira/browse/ASTERIXDB-3103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Wail Y. Alkowaileet updated ASTERIXDB-3103:
-------------------------------------------
Component/s: COMP - Compiler
> Non-pure functions are not referenced correctly
> -----------------------------------------------
>
> Key: ASTERIXDB-3103
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-3103
> Project: Apache AsterixDB
> Issue Type: Bug
> Components: COMP - Compiler
> Affects Versions: 0.9.7
> Reporter: Wail Y. Alkowaileet
> Assignee: Wail Y. Alkowaileet
> Priority: Major
> Fix For: 0.9.9
>
>
>
> Currently, `LangExpressionToPlanTranslator` inlines every expression –
> including non-pure functions. This could lead to incorrect referencing as
> follows
> Query:
> {code:java}
> EXPLAIN
> SELECT *
> FROM [1, 2, 3] AS A
> LIMIT random() {code}
>
> Plan:
> {code:java}
> distribute result [$$13]
> -- DISTRIBUTE_RESULT |UNPARTITIONED|
> exchange
> -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
> limit switch-case(gt(treat-as-integer(random()), 0), true,
> treat-as-integer(random()), 0)
> -- STREAM_LIMIT |UNPARTITIONED|
> project ([$$13])
> -- STREAM_PROJECT |UNPARTITIONED|
> assign [$$13] <- [{\"A\": $$A}]
> -- ASSIGN |UNPARTITIONED|
> limit switch-case(gt(treat-as-integer(random()), 0), true,
> treat-as-integer(random()), 0)
> -- STREAM_LIMIT |UNPARTITIONED|
> unnest $$A <- scan-collection(array: [ 1, 2, 3 ])
> -- UNNEST |UNPARTITIONED|
> empty-tuple-source
> -- EMPTY_TUPLE_SOURCE |UNPARTITIONED| {code}
>
> In:
> {code:java}
> limit switch-case(gt(treat-as-integer(random()), 0), true,
> treat-as-integer(random()), 0) {code}
> the test *gt(treat-as-integer(random()), 0)* could yield a positive number;
> however, the second call *treat-as-integer(random())* could yield a negative
> number – rendering this check ({*}switch-case{*} call) as useless
>
> The expected behavior is that the value from *random()* should be in its own
> assign
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)