You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Alessandro Solimando (Jira)" <ji...@apache.org> on 2022/10/17 13:53:00 UTC

[jira] [Comment Edited] (HIVE-26643) HiveUnionPullUpConstantsRule produces an invalid plan when pulling up constants for nullable fields

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

Alessandro Solimando edited comment on HIVE-26643 at 10/17/22 1:52 PM:
-----------------------------------------------------------------------

A similar issue was fixed in this Calcite ticket for {_}AggregateProjectPullUpConstantsRule{_}, see [https://github.com/apache/calcite/commit/aa25dcbe565196fb6b78149042ee817427ed4f68#diff-ff4ebbdcaabdec1969e88cbeb4fa7519f5f867d9abdce2a333e1ebc8fc549a47R172-R176] from CALCITE-2179


was (Author: asolimando):
A similar issue was fixed in this Calcite ticket for _AggregateProjectPullUpConstantsRule_, see https://github.com/apache/calcite/commit/aa25dcbe565196fb6b78149042ee817427ed4f68#diff-ff4ebbdcaabdec1969e88cbeb4fa7519f5f867d9abdce2a333e1ebc8fc549a47R172-R176

> HiveUnionPullUpConstantsRule produces an invalid plan when pulling up constants for nullable fields
> ---------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-26643
>                 URL: https://issues.apache.org/jira/browse/HIVE-26643
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>    Affects Versions: 4.0.0-alpha-2
>            Reporter: Alessandro Solimando
>            Assignee: Alessandro Solimando
>            Priority: Major
>
> The rule does pull up constants without checking/adjusting nullability to match that of the field type. 
> Here is the stack-trace when a nullable type is involved:
> {code:java}
> java.lang.AssertionError: Cannot add expression of different type to set:
> set type is RecordType(JavaType(class java.lang.Integer) f1, JavaType(int) NOT NULL f2) NOT NULL
> expression type is RecordType(JavaType(int) NOT NULL f1, JavaType(int) NOT NULL f2) NOT NULL
> set is rel#38:HiveUnion.(input#0=HepRelVertex#35,input#1=HepRelVertex#35,all=true)
> expression is HiveProject(f1=[1], f2=[$0])
>   HiveUnion(all=[true])
>     HiveProject(f2=[$1])
>       HiveProject(f1=[$0], f2=[$1])
>         HiveFilter(condition=[=($0, 1)])
>           LogicalTableScan(table=[[]])
>     HiveProject(f2=[$1])
>       HiveProject(f1=[$0], f2=[$1])
>         HiveFilter(condition=[=($0, 1)])
>           LogicalTableScan(table=[[]])
> {code}
> The solution is to check nullability and add a cast when the field is nullable, since the constant's type is not.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)