You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Aman Sinha (JIRA)" <ji...@apache.org> on 2015/02/28 20:27:04 UTC

[jira] [Resolved] (DRILL-2328) Concat operator returns wrong result when one of the operands is NULL

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

Aman Sinha resolved DRILL-2328.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 0.8.0
         Assignee: Sean Hsuan-Yi Chu  (was: Aman Sinha)

Committed fix in master branch: c8a241b06
Marking this for 0.8. 
Note for QA:  When verifying this issue, please check the external documentation - you may need to create a JIRA for the Doc team to describe the behavior of the || operator versus concat function. 

> Concat operator returns wrong result when one of the operands is NULL
> ---------------------------------------------------------------------
>
>                 Key: DRILL-2328
>                 URL: https://issues.apache.org/jira/browse/DRILL-2328
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 0.8.0
>            Reporter: Victoria Markman
>            Assignee: Sean Hsuan-Yi Chu
>            Priority: Critical
>             Fix For: 0.8.0
>
>         Attachments: DRILL-2328.1.patch
>
>
> Queries below should return NULL:
> {code}
> 0: jdbc:drill:schema=dfs> select cast(null as varchar(10)) || '--' from t1;
> +------------+
> |   EXPR$0   |
> +------------+
> | --         |
> | --         |
> | --         |
> | --         |
> | --         |
> | --         |
> | --         |
> | --         |
> | --         |
> | --         |
> +------------+
> 10 rows selected (0.09 seconds)
> 0: jdbc:drill:schema=dfs> select a1 || '--' from t1 where a1 is null;
> +------------+
> |   EXPR$0   |
> +------------+
> | --         |
> +------------+
> 1 row selected (0.105 seconds)
> {code}
> Looks harmless at first, but a very common pattern in many customer queries will be broken: grouping by using '||' as following:
> {code}
> select
>         cast(extract(day from c_timestamp) as varchar(10)) || '-' || cast(extract(month from c_timestamp) as varchar(10)) || '-' || cast(extract(year from c_timestamp) as varchar(10)),
>         sum(c_integer)  as sum1
> from
>         alltypes_with_nulls
> group by
>         cast(extract(day from c_timestamp) as varchar(10)) || '-' || cast(extract(month from c_timestamp) as varchar(10)) || '-' || cast(extract(year from c_timestamp) as varchar(10))
> order by
>         cast(extract(day from c_timestamp) as varchar(10)) || '-' || cast(extract(month from c_timestamp) as varchar(10)) || '-' || cast(extract(year from c_timestamp) as varchar(10))
> ;
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)