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/09/16 17:35:00 UTC

[jira] [Commented] (CALCITE-2562) Suspicious code in org.apache.calcite.sql2rel.StandardConvertletTable#convertDatetimeMinus

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

Julian Hyde commented on CALCITE-2562:
--------------------------------------

It looks as if the casts are dead code and can be removed.

> Suspicious code in org.apache.calcite.sql2rel.StandardConvertletTable#convertDatetimeMinus
> ------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2562
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2562
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>
> https://github.com/apache/calcite/blob/ca858dd725dea6bf9b4a9059cf1c3ba98bd82f26/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java#L626-L640
> {code:java}    final RexNode[] casts = new RexNode[2];
>     casts[0] =
>         rexBuilder.makeCast(
>             cx.getTypeFactory().createTypeWithNullability(
>                 int8Type,
>                 exprs.get(0).getType().isNullable()),
>             exprs.get(0));
>     casts[1] =
>         rexBuilder.makeCast(
>             cx.getTypeFactory().createTypeWithNullability(
>                 int8Type,
>                 exprs.get(1).getType().isNullable()),
>             exprs.get(1));
>     final RelDataType resType =
>         cx.getValidator().getValidatedNodeType(call);
>     return rexBuilder.makeCall(resType, op, exprs.subList(0, 2));
> {code}
> {{casts}} array is never read.
> Are casts required there?
> Should {{Arrays.asList(casts)}} be used instead of {{exprs.subList(0, 2)}}?



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