You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Volodymyr Vysotskyi (JIRA)" <ji...@apache.org> on 2017/12/01 10:22:00 UTC

[jira] [Comment Edited] (CALCITE-2069) RexSimplify.removeNullabilityCast() always removes cast for operand with ANY type

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

Volodymyr Vysotskyi edited comment on CALCITE-2069 at 12/1/17 10:21 AM:
------------------------------------------------------------------------

Thank you all for responses.
[~amansinha100], this change did not bring any additional regression or unit test failures.
[~laurentgo], yes, this problem appeared in Calcite-1.13.0.
[~julianhyde], I have updated the test in pull request in the same commit, so currently it is the last fix-up from my side.


was (Author: vvysotskyi):
Thank you all for responses.
[~amansinha100], this change did not bring any additional regression or unit test failures.
[~julianhyde], I have updated the test in pull request in the same commit, so currently it is the last fix-up from my side.

> RexSimplify.removeNullabilityCast() always removes cast for operand with ANY type
> ---------------------------------------------------------------------------------
>
>                 Key: CALCITE-2069
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2069
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Volodymyr Vysotskyi
>            Assignee: Julian Hyde
>             Fix For: 1.16.0
>
>
> When a field is received from Dynamic Table, its type left {{ANY}}, and it is used in the filter condition with the cast, which actually should produce physical cast (for example we are trying to cast varchar to boolean) {{RexSimplify.removeNullabilityCast()}} removes this cast and lefts only field in condition.
> This test helps to observe this issue:
> {code:java}
>   @Test public void testFilterCastAny() {
>     final RelBuilder builder = RelBuilder.create(config().build());
>     final RelDataType intType = builder.getTypeFactory().createSqlType(SqlTypeName.ANY);
>     RelNode root =
>         builder.scan("EMP")
>             .filter(
>                 builder.cast(
>                     builder.patternField("varchar_field", intType, 0),
>                     SqlTypeName.BOOLEAN))
>             .build();
>     assertThat(str(root),
>         is("LogicalFilter(condition=[CAST(varchar_field.$0):BOOLEAN NOT NULL])\n"
>             + "  LogicalTableScan(table=[[scott, EMP]])\n"));
>   }
> {code}
> It happens because {{SqlTypeUtil.equalSansNullability()}} returns true if any of its arguments has {{ANY}} type.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)