You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2018/03/02 16:58:00 UTC

[jira] [Comment Edited] (CALCITE-2198) ClassCastException in RexBuilder when makeLiteral for BINARY and VARBINARY

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

Julian Hyde edited comment on CALCITE-2198 at 3/2/18 4:57 PM:
--------------------------------------------------------------

By the way, many people these days use {{RelBuilder}} to build both {{RelNode}} and {{RexNode}} instances - it is becoming more popular than {{RexBuilder}} - so they would be calling {{RelBuilder.literal(Object)}}. That method has similar problems with documentation – and in fact, eyeballing the code, doesn't support creating {{BINARY}} literals at all. We should fix that.


was (Author: julianhyde):
By the way, many people these days use {{RelBuilder}} to build both {{RelNode}}s and {{RexNode}}s, so they would be calling {{RelBuilder.literal(Object)}}. That method has similar problems with documentation – and in fact, eyeballing the code, doesn't support creating {{BINARY}} literals at all. We should fix that.

> ClassCastException in RexBuilder when makeLiteral for BINARY and VARBINARY
> --------------------------------------------------------------------------
>
>                 Key: CALCITE-2198
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2198
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Hequn Cheng
>            Assignee: Julian Hyde
>            Priority: Major
>
> Currently, makeLiteral for {{BINARY}} and {{VARBINARY}} will throw {{ClassCastException}} when value type is {{byte[]}}:
> {code:java}
> java.lang.ClassCastException: [B cannot be cast to org.apache.calcite.avatica.util.ByteString
> at org.apache.calcite.rex.RexBuilder.makeLiteral(RexBuilder.java:1336)
> at org.apache.calcite.test.RexProgramTest.testSimplifyCastLiteral(RexProgramTest.java:1567){code}
> The exception can be reproduced by the following test case(in RexProgramTest.testSimplifyCastLiteral()):
> {code:java}
> literals.add((RexLiteral)
>     rexBuilder.makeLiteral(new byte[] {1, 2, -34, 0, -128},
>         typeFactory.createSqlType(SqlTypeName.BINARY, 5), false));{code}
> To avoid this exception we have to add support for type of  {{byte[]}}. One choice is to convert {{byte[]}} to {{ByteString}} in {{RexBuilder.clean()}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)