You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jungtaek Lim (JIRA)" <ji...@apache.org> on 2016/09/27 05:12:20 UTC

[jira] [Commented] (CALCITE-1386) ITEM operator seems to ignore the value type of collection and assign the value to Object

    [ https://issues.apache.org/jira/browse/CALCITE-1386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15525095#comment-15525095 ] 

Jungtaek Lim commented on CALCITE-1386:
---------------------------------------

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.

> ITEM operator seems to ignore the value type of collection and assign the value to Object
> -----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-1386
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1386
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.9.0
>            Reporter: Jungtaek Lim
>            Assignee: Julian Hyde
>
> Suppose we're defining the following table:
> {code}
> .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))
> {code}
> and query like this:
> {code}
> SELECT * FROM <TBL> WHERE MAPFIELD['a'] = 1
> {code}
> 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.)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)