Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-2101

Decimal literals are treated as double

    XMLWordPrintableJSON

Details

    Description

      create table t1(c1) as
      select
              cast(null as decimal(28,4))
      from `t1.csv`;
      
      message root {
        optional double c1; <-- Wrong, should be decimal
      }
      

      This is very commonly used construct to convert csv files to parquet files, that's why I'm marking this bug as critical.

      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`;
      

      Correct - cast string literal to decimal

      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));
      }
      

      Correct - cast literal from csv file as decimal

      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));
      }
      

      Correct - case statement (no null involved)

      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));
      }
      

      Attachments

        1. DRILL-2101.patch
          18 kB
          Mehant Baid
        2. DRILL-2101-PARTIAL-PATCH-enable-decimal-literals.patch
          1 kB
          Jason Altekruse

        Issue Links

          Activity

            People

              volodymyr Vova Vysotskyi
              vicky Victoria Markman
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: