[ 
https://issues.apache.org/jira/browse/DRILL-6722?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Zinoviev updated DRILL-6722:
---------------------------------
    Comment: was deleted

(was: At this stage, it seems to me that the whole logic of the 
ScalarReplacementNode is broken. Neither the variable index in ValueHolderSub, 
nor mapping local variable to frame slot in MethodAnalyzer does not track 
source code control flow.

Bug reason:
Then
ALOAD[P]
ASTORE[N]
executes, ValueHolderSub linked with variable P changes it's `first` field to N 
holder `first` field. Since ValueHolderSub shared between all variables, linked 
to him, it leads to all this varaibles become assigned to N.

If I make first field final, CASE fails:
CASE compiles into 

{code:java}
var res;
if (expression) {
 res = v1;
else {
 res = v2;
}
{code}


Then Analyzer calculates Frame variables, it ignores if - else logic and 
assigne v2 to res slot.
P.S. 
https://stackoverflow.com/questions/25109942/is-there-a-better-explanation-of-stack-map-frames
 
Can be Analyzed is intended only for variable type inferrence?

)

> Query from parquet with case-then and arithmetic operation returns a wrong 
> result
> ---------------------------------------------------------------------------------
>
>                 Key: DRILL-6722
>                 URL: https://issues.apache.org/jira/browse/DRILL-6722
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Codegen
>    Affects Versions: 1.14.0
>            Reporter: Oleg Zinoviev
>            Priority: Major
>         Attachments: JaininoJava.class, JaininoJava2_merged.class, 
> correct.csv, result.csv
>
>
> Steps to reproduce:
> 1) Create sample table:
> {code:sql}
> create table dfs.tmp.test as 
>   select 1 as a, 2 as b
>   union all
>   select 3 as a, 2 as b
>   union all
>   select 1 as a, 4 as b
>   union all
>   select 2 as a, 2 as b
> {code}
> 2)  Execute query:
> {code:sql}
> select
>   case when s.a > s.b then s.a else s.b end as b, 
>   abs(s.a - s.b) as d
> from dfs.tmp.test s
> {code}
> 3) Drill returns:  [^result.csv] 
> 4) Result of query without parquet:
> {code:sql}
> select 
>       case when s.a > s.b then s.a else s.b end as b, 
>       abs(s.a - s.b) as d
> from (
>       select 1 as a, 2 as b
>       union all
>       select 3 as a, 2 as b
>       union all
>       select 1 as a, 4 as b
>       union all
>       select 2 as a, 2 as b
> ) s
> {code}
>  [^correct.csv] 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to