Hive
  1. Hive
  2. HIVE-1703

BOOL types should implicitly cast to INT

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Query Processor
    • Labels:
      None

      Description

      From the Wiki:
      "Otherwise, the operator is probably a UDF/UDAF function. In that case, we will try to convert the parameters to the types that are accepted by the UDF/UDAF function. If the UDF/UDAF function is overloaded (with more than 1 implementations with different types), we will try to find the one with least number of type conversions needed."

      However,
      SELECT SUM(thing=otherthing) FROM table
      ...fails, because thing=otherthing is a bool, and there is no system by which BOOL would convert to INT, as it should. INT is higher precision, so this should always work. Explicit casting, SUM(CAST(thing=otherthing AS INT)) works just fine.

      (yes, in this simple case COUNT(1) WHERE thing=otherthing would do the job, but it serves to illustrate the bug.)

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Xuefu Zhang
            Reporter:
            Adam Kramer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development