Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1386

ITEM operator ignores the value type of the collection, assigns to Object variable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.0
    • Fix Version/s: 1.10.0
    • Component/s: core
    • Labels:
      None

      Description

      Suppose we're defining the following table:

      .field("ID", SqlTypeName.INTEGER)
      .field("MAPFIELD",
              typeFactory.createMapType(
                      typeFactory.createSqlType(SqlTypeName.VARCHAR),
                      typeFactory.createTypeWithNullability(
                              typeFactory.createSqlType(SqlTypeName.INTEGER), true)))
      .field("NESTEDMAPFIELD",
              typeFactory.createMapType(
                      typeFactory.createSqlType(SqlTypeName.VARCHAR),
                      typeFactory.createTypeWithNullability(
                              typeFactory.createMapType(
                                      typeFactory.createSqlType(SqlTypeName.VARCHAR),
                                      typeFactory.createTypeWithNullability(
                                              typeFactory.createSqlType(SqlTypeName.INTEGER), true))
                              , true)))
      .field("ARRAYFIELD", typeFactory.createArrayType(
              typeFactory.createTypeWithNullability(
                      typeFactory.createSqlType(SqlTypeName.INTEGER), true), -1L))
      

      and query like this:

      SELECT * FROM <TBL> WHERE MAPFIELD['a'] = 1
      

      When we evaluate that query, JaninoRexCompiler throws an Exception saying there's no SqlFunctions.eq(Object, int).

      I took a breakpoint on BinaryImplementor.implement() to see variables just before compiler finds SqlFunctions.eq().
      The type of expression is Object which is not generic, but seems like matching RexCall operand have value type information.
      (I mean type mismatch occurs.)

        Issue Links

          Activity

          Hide
          kabhwan Jungtaek Lim added a comment -

          This breaks accessing nested map with defining type in detail. Assigning type to ANY can resolve accessing nested map, while it still need to wrap the value to CAST to compare with integer literal.

          Show
          kabhwan Jungtaek Lim added a comment - This breaks accessing nested map with defining type in detail. Assigning type to ANY can resolve accessing nested map, while it still need to wrap the value to CAST to compare with integer literal.
          Hide
          kabhwan Jungtaek Lim added a comment -

          I submitted pull request for this issue: https://github.com/apache/calcite/pull/283

          Please grant me to the contributor list for Calcite project. Thanks!

          Show
          kabhwan Jungtaek Lim added a comment - I submitted pull request for this issue: https://github.com/apache/calcite/pull/283 Please grant me to the contributor list for Calcite project. Thanks!
          Hide
          julianhyde Julian Hyde added a comment -

          I did a quick review and the patch looks good, but can you please add some tests?

          Show
          julianhyde Julian Hyde added a comment - I did a quick review and the patch looks good, but can you please add some tests?
          Hide
          kabhwan Jungtaek Lim added a comment -

          Julian Hyde
          Addressed unit tests, and squashed commits into one. Please have a look.

          Show
          kabhwan Jungtaek Lim added a comment - Julian Hyde Addressed unit tests, and squashed commits into one. Please have a look.
          Hide
          julianhyde Julian Hyde added a comment -
          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/963876bb . Thanks for the PR, Jungtaek Lim !
          Hide
          julianhyde Julian Hyde added a comment - - edited

          Assigned it to you, Jungtaek Lim, since you did the work! Also I've made you a contributor in JIRA, as you asked.

          Show
          julianhyde Julian Hyde added a comment - - edited Assigned it to you, Jungtaek Lim , since you did the work! Also I've made you a contributor in JIRA, as you asked.
          Hide
          kabhwan Jungtaek Lim added a comment -

          Julian Hyde Thanks for reviewing and merging!

          Show
          kabhwan Jungtaek Lim added a comment - Julian Hyde Thanks for reviewing and merging!
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          Resolved in release 1.10.0 (2016-10-12).

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.10.0 (2016-10-12).

            People

            • Assignee:
              kabhwan Jungtaek Lim
              Reporter:
              kabhwan Jungtaek Lim
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development