[
https://issues.apache.org/jira/browse/ASTERIXDB-3103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Wail Y. Alkowaileet updated ASTERIXDB-3103:
-------------------------------------------
Description:
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
was:
Currently, `LangExpressionToPlanTranslator` inlines every expression –
including non-pure functions. This could lead to incorrect referencing as
follows
Query:
{code:java}
EXPLAIN
SELECT COUNT(*)
FROM [1, 2, 3] AS A
LIMIT random() {code}
Plan:
{code:java}
distribute result [$$32]
-- DISTRIBUTE_RESULT |LOCAL|
exchange
-- ONE_TO_ONE_EXCHANGE |LOCAL|
limit switch-case(gt(treat-as-integer(random()), 0), true,
treat-as-integer(random()), 0)
-- STREAM_LIMIT |LOCAL|
project ([$$32])
-- STREAM_PROJECT |LOCAL|
assign [$$32] <- [{\"$1\": $$34}]
-- ASSIGN |LOCAL|
limit switch-case(gt(treat-as-integer(random()), 0), true,
treat-as-integer(random()), 0)
-- STREAM_LIMIT |LOCAL|
aggregate [$$34] <- [agg-sql-sum($$35)]
-- AGGREGATE |LOCAL|
aggregate [$$35] <- [agg-sql-count(1)]
-- AGGREGATE |LOCAL|
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
> 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
> 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)