Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-1837

Failed DCHECK about literal decimal size when using COALESCE()

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: Impala 2.2
    • Fix Version/s: Impala 2.2
    • Component/s: None
    • Labels:
      None

      Description

      The first query below triggers some sort of edge case about decimal size. If the "1.8" is changed to "1.7" the query runs fine. Also if an addition is done instead of coalesce, it works.

      [localhost:21000] > select coalesce(cast(0 as decimal(38,38)), 1.8);
      Query: select coalesce(cast(0 as decimal(38,38)), 1.8)
      Error communicating with impalad: TSocket read 0 bytes
      
      [localhost:21000] > select coalesce(cast(0 as decimal(38,38)), 1.7);
      Query: select coalesce(cast(0 as decimal(38,38)), 1.7)
      +------------------------------------------+
      | coalesce(cast(0 as decimal(38,38)), 1.7) |
      +------------------------------------------+
      | 0.00000000000000000000000000000000000000 |
      +------------------------------------------+
      Fetched 1 row(s) in 0.14s
      
      [localhost:21000] > select cast(0 as decimal(38,38)) + 1.8;
      Query: select cast(0 as decimal(38,38)) + 1.8
      +---------------------------------+
      | cast(0 as decimal(38,38)) + 1.8 |
      +---------------------------------+
      | NULL                            |
      +---------------------------------+
      WARNINGS: UDF WARNING: Expression overflowed, returning NULL
      

      The last line has the failed dcheck, the len is 17.

          case TYPE_DECIMAL: {                                                                  
            DCHECK_EQ(node.node_type, TExprNodeType::DECIMAL_LITERAL);                          
            DCHECK(node.__isset.decimal_literal);                                               
            const uint8_t* buffer =                                                             
                reinterpret_cast<const uint8_t*>(&node.decimal_literal.value[0]);               
            int len = node.decimal_literal.value.size();                                        
            DCHECK_GT(len, 0);                                                                  
                                                                                                
            switch (type().GetByteSize()) {                                                     
              case 4:                                                                           
                DCHECK_LE(len, 4);                                                              
                DecimalUtil::DecodeFromFixedLenByteArray(buffer, len, &value_.decimal4_val);    
                break;                                                                          
              case 8:                                                                           
                DCHECK_LE(len, 8);                                                              
                DecimalUtil::DecodeFromFixedLenByteArray(buffer, len, &value_.decimal8_val);    
                break;                                                                          
              case 16:                                                                          
                DCHECK_LE(len, 16);
      

      F0302 17:41:52.358654 31911 literal.cc:110] Check failed: len <= 16 (17 vs. 16)

        Attachments

          Activity

            People

            • Assignee:
              alex.behm Alexander Behm
              Reporter:
              caseyc casey
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: