You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Victoria Markman (JIRA)" <ji...@apache.org> on 2015/01/28 23:52:35 UTC

[jira] [Created] (DRILL-2101) Incorrect data type is written to parquet file when NULL is cast to decimal

Victoria Markman created DRILL-2101:
---------------------------------------

             Summary: Incorrect data type is written to parquet file when NULL is cast to decimal
                 Key: DRILL-2101
                 URL: https://issues.apache.org/jira/browse/DRILL-2101
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 0.8.0
            Reporter: Victoria Markman
            Priority: Critical


{code}
create table t1(c1) as
select
        cast(null as decimal(28,4))
from `t1.csv`;

message root {
  optional double c1; <-- Wrong, should be decimal
}
{code}

This is very commonly used construct to convert csv files to parquet files, that's why I'm marking this bug as critical.
{code}
create table t2 as 
select
        case when columns[3] = '' then cast(null as decimal(28,4)) else cast(columns[3] as decimal(28, 4)) end
from `t1.csv`;
{code}


Correct - cast string literal to decimal
{code}
create table t3(c1) as
select
        cast('12345678901234567890.1234' as decimal(28,4))
from `t1.csv`;

message root {
  required fixed_len_byte_array(12) c1 (DECIMAL(28,4));
}
{code}

Correct - cast literal from csv file as decimal

{code}
create table t4(c1) as
select
        cast(columns[3] as decimal(28,4))
from `t1.csv`;

message root {
  optional fixed_len_byte_array(12) c1 (DECIMAL(28,4));
}
{code}

Correct - case statement (no null involved)

{code}
create table t5(c1) as
select
        case when columns[3] = '' then cast('1111' as decimal(28,4)) else cast(columns[3] as decimal(28,4)) end
from `t1.csv`;

message root {
  optional fixed_len_byte_array(12) c1 (DECIMAL(28,4));
}
{code}




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