You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Sergey (Jira)" <ji...@apache.org> on 2022/09/07 08:47:00 UTC

[jira] [Comment Edited] (HIVE-21778) CBO: "Struct is not null" gets evaluated as `nullable` always causing filter miss in the query

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

Sergey edited comment on HIVE-21778 at 9/7/22 8:46 AM:
-------------------------------------------------------

[ql/src/test/queries/clientpositive/structin.q|https://github.com/apache/hive/pull/928/files#diff-5e07f847d74d58dcf1f07b57748da8b2bab7aa65635fd50594ca72bf0f066371] - not full test, test no have "set hive.cbo.enable=true".


was (Author: JIRAUSER295463):
[ql/src/test/queries/clientpositive/structin.q|https://github.com/apache/hive/pull/928/files#diff-5e07f847d74d58dcf1f07b57748da8b2bab7aa65635fd50594ca72bf0f066371] - not full test, test no have set hive.cbo.enable=true.

> CBO: "Struct is not null" gets evaluated as `nullable` always causing filter miss in the query
> ----------------------------------------------------------------------------------------------
>
>                 Key: HIVE-21778
>                 URL: https://issues.apache.org/jira/browse/HIVE-21778
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>    Affects Versions: 2.3.5, 4.0.0
>            Reporter: Rajesh Balamohan
>            Assignee: Vineet Garg
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0, 4.0.0-alpha-1
>
>         Attachments: HIVE-21778.1.patch, HIVE-21778.2.patch, HIVE-21778.3.patch, HIVE-21778.4.patch, HIVE-21778.5.patch, HIVE-21778.6.patch, HIVE-21778.7.patch, HIVE-21778.8.patch, test_null.q, test_null.q.out
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> {noformat}
> drop table if exists test_struct;
> CREATE external TABLE test_struct
> (
>   f1 string,
>   demo_struct struct<f1:string, f2:string, f3:string>,
>   datestr string
> );
> set hive.cbo.enable=true;
> explain select * from etltmp.test_struct where datestr='2019-01-01' and demo_struct is not null;
> STAGE PLANS:
>   Stage: Stage-0
>     Fetch Operator
>       limit: -1
>       Processor Tree:
>         TableScan
>           alias: test_struct
>           filterExpr: (datestr = '2019-01-01') (type: boolean) <----- Note that demo_struct filter is not added here
>           Filter Operator
>             predicate: (datestr = '2019-01-01') (type: boolean)
>             Select Operator
>               expressions: f1 (type: string), demo_struct (type: struct<f1:string,f2:string,f3:string>), '2019-01-01' (type: string)
>               outputColumnNames: _col0, _col1, _col2
>               ListSink
> set hive.cbo.enable=false;
> explain select * from etltmp.test_struct where datestr='2019-01-01' and demo_struct is not null;
> STAGE PLANS:
>   Stage: Stage-0
>     Fetch Operator
>       limit: -1
>       Processor Tree:
>         TableScan
>           alias: test_struct
>           filterExpr: ((datestr = '2019-01-01') and demo_struct is not null) (type: boolean) <----- Note that demo_struct filter is added when CBO is turned off
>           Filter Operator
>             predicate: ((datestr = '2019-01-01') and demo_struct is not null) (type: boolean)
>             Select Operator
>               expressions: f1 (type: string), demo_struct (type: struct<f1:string,f2:string,f3:string>), '2019-01-01' (type: string)
>               outputColumnNames: _col0, _col1, _col2
>               ListSink
> {noformat}
> In CalcitePlanner::genFilterRelNode, the following code misses to evaluate this filter. 
> {noformat}
> RexNode factoredFilterExpr = RexUtil
>           .pullFactors(cluster.getRexBuilder(), convertedFilterExpr);
> {noformat}
> Note that even if we add `demo_struct.f1` it would end up pushing the filter correctly. 



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