Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-2249

When creating constant expression for numbers, try to infer type from another comparison operand, instead of trying to use integer first, and then long and double

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.0
    • Component/s: None
    • Labels:
      None

      Description

      The current code to build constant expression for numbers, here is the code:

      try

      { v = Double.valueOf(expr.getText()); v = Long.valueOf(expr.getText()); v = Integer.valueOf(expr.getText()); }

      catch (NumberFormatException e)

      { // do nothing here, we will throw an exception in the following block }

      if (v == null)

      { throw new SemanticException(ErrorMsg.INVALID_NUMERICAL_CONSTANT .getMsg(expr)); }

      return new ExprNodeConstantDesc(v);

      The for the case that "WHERE <BIG_INT_COLUMN> = 0", or "WHERE <DOUBLE_COLUMN> = 0", we always have to do a type conversion when comparing, which is unnecessary if it is slightly smarter to choose type when creating the constant expression. We can simply walk one level up the tree, find another comparison party and use the same type with that one if it is possible. For user's wrong query like '<INT_COLUMN>=1.1', we can even do more.

        Attachments

        1. ASF.LICENSE.NOT.GRANTED--HIVE-2249.D1383.4.patch
          254 kB
          Phabricator
        2. ASF.LICENSE.NOT.GRANTED--HIVE-2249.D1383.3.patch
          235 kB
          Phabricator
        3. ASF.LICENSE.NOT.GRANTED--HIVE-2249.D1383.2.patch
          232 kB
          Phabricator
        4. ASF.LICENSE.NOT.GRANTED--HIVE-2249.D1383.1.patch
          206 kB
          Phabricator
        5. HIVE-2249.2.patch.txt
          215 kB
          Zhiqiu Kong
        6. HIVE-2249.1.patch.txt
          46 kB
          Joseph Barillari

          Issue Links

            Activity

              People

              • Assignee:
                zhiqiu Zhiqiu Kong
                Reporter:
                sdong Siying Dong
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: