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

Evaluation of a constant boolean expr results in a NULL instead of FALSE.

    Details

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

      Description

      When folding constant expressions Impala may incorrectly replace a constant boolean expression with NULL instead of FALSE. This may lead to incorrect results.

      Repro:

      explain select * from functional_kudu.alltypes
      where bool_col = (true and false);
      
      +------------------------------------------------------------------------------------+
      | Explain String                                                                     |
      +------------------------------------------------------------------------------------+
      | Estimated Per-Host Requirements: Memory=0B VCores=1                                |
      | WARNING: The following tables are missing relevant table and/or column statistics. |
      | functional_kudu.alltypes                                                           |
      |                                                                                    |
      | PLAN-ROOT SINK                                                                     |
      | |                                                                                  |
      | 01:EXCHANGE [UNPARTITIONED]                                                        |
      | |                                                                                  |
      | 00:SCAN KUDU [functional_kudu.alltypes]                                            |
      |    predicates: bool_col = NULL      <--- Should be FALSE                                               |
      +------------------------------------------------------------------------------------+
      

      The underlying issue is a simple one. We are not calling the correct isSet() function on a thrift struct. See LiteralExpr.create():

      ...
      case BOOLEAN:
        if (val.isBool_val()) result = new BoolLiteral(val.bool_val);
        break;
      ...
      

      The check should be: val.isSetBool_val()

        Activity

        Hide
        alex.behm Alexander Behm added a comment -

        commit 91b5264e5239b2cf3ad4ea896eb28dd5fbdcb74a
        Author: Alex Behm <alex.behm@cloudera.com>
        Date: Mon Nov 14 15:44:10 2016 -0800

        IMPALA-4479: Use correct isSet() thrift function when evaluating constant bool exprs.

        Change-Id: Ie3ba195a5241ca630bd0cf71b83d423733b06546
        Reviewed-on: http://gerrit.cloudera.org:8080/5088
        Reviewed-by: Alex Behm <alex.behm@cloudera.com>
        Tested-by: Internal Jenkins

        Show
        alex.behm Alexander Behm added a comment - commit 91b5264e5239b2cf3ad4ea896eb28dd5fbdcb74a Author: Alex Behm <alex.behm@cloudera.com> Date: Mon Nov 14 15:44:10 2016 -0800 IMPALA-4479 : Use correct isSet() thrift function when evaluating constant bool exprs. Change-Id: Ie3ba195a5241ca630bd0cf71b83d423733b06546 Reviewed-on: http://gerrit.cloudera.org:8080/5088 Reviewed-by: Alex Behm <alex.behm@cloudera.com> Tested-by: Internal Jenkins

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development