Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      For instance,
      select ANY type || ANY type ... leads assertion error from:
      assert (precision >= 0) || (precision == RelDataType.PRECISION_NOT_SPECIFIED);
      (SqlTypeFactoryImpl.java( line: 62))

      Essentially, it is because, SqlReturnTypeInference of `||` is DYADIC_STRING_SUM_PRECISION. When doing inference for the return type, there is one data field in DYADIC_STRING_SUM_PRECISION called "precision", which is calculated as arg0.precison + arg1.precision.

      However, for ANY type, the precision is defined as -1. So the above calculation will give "-2" for ANY type operands, in turn, breaking up the assertion.

      Moreover, `||` can fail when the two operands have different types (e.g., ANY type || String). In the No schema system, ANY type can be quite prevalent. For example, select ANY type || string || ANY type ... where, in addition to two ANY types on two sides, we have a string in between.

      1. CALCITE-583.1.patch
        3 kB
        Sean Hsuan-Yi Chu
      2. CALCITE-583.2.patch
        4 kB
        Sean Hsuan-Yi Chu

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Can you add a test case to SqlOperatorBaseTest?

        Show
        julianhyde Julian Hyde added a comment - Can you add a test case to SqlOperatorBaseTest?
        Hide
        seanhychu Sean Hsuan-Yi Chu added a comment -

        I added this one:

        tester.checkNull(" cast(null as ANY) || cast(null as ANY) ");

        Show
        seanhychu Sean Hsuan-Yi Chu added a comment - I added this one: tester.checkNull(" cast(null as ANY) || cast(null as ANY) ");
        Hide
        seanhychu Sean Hsuan-Yi Chu added a comment -
        Show
        seanhychu Sean Hsuan-Yi Chu added a comment - Send a pull request https://github.com/apache/incubator-calcite/pull/47
        Hide
        julianhyde Julian Hyde added a comment -

        Got it. Can't accept the pull request until release 1.0 has closed.

        Show
        julianhyde Julian Hyde added a comment - Got it. Can't accept the pull request until release 1.0 has closed.
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/8afdd01f .
        Hide
        julianhyde Julian Hyde added a comment -

        Closing now that 1.1.0-incubating has been released.

        Show
        julianhyde Julian Hyde added a comment - Closing now that 1.1.0-incubating has been released.

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            seanhychu Sean Hsuan-Yi Chu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development