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

Shohei Okumiya edited comment on HIVE-28705 at 1/28/25 10:43 AM:
-----------------------------------------------------------------

I am just testing the repro query on my local machine.
{code:java}
explain select id from t1 where (case when month='2023-07' then false else true 
END); {code}
With CBO, the predicate is partially evaluated as `(month = '2023-07') is not 
true`.
{code:java}
+----------------------------------------------------+
|                      Explain                       |
+----------------------------------------------------+
| Plan optimized by CBO.                             |
|                                                    |
| Stage-0                                            |
|   Fetch Operator                                   |
|     limit:-1                                       |
|     Select Operator [SEL_2]                        |
|       Output:["_col0"]                             |
|       Filter Operator [FIL_4]                      |
|         predicate:(month = '2023-07') is not true  |
|         TableScan [TS_0]                           |
|           Output:["id"]                            |
|                                                    |
+----------------------------------------------------+ {code}
Output of EXPLAIN CBO.
{code:java}
+----------------------------------------------------+
|                      Explain                       |
+----------------------------------------------------+
| CBO PLAN:                                          |
| HiveProject(id=[$0])                               |
|   HiveFilter(condition=[IS NOT TRUE(=($1, _UTF-16LE'2023-07'))]) |
|     HiveTableScan(table=[[default, t1]], table:alias=[t1]) |
|                                                    |
+----------------------------------------------------+ {code}
 

Without CBO, no predicate is pushed. I remember there is an optimizer to remove 
redundant predicates(PartitionPruner? I forgot).
{code:java}
+------------------------------+
|           Explain            |
+------------------------------+
| Stage-0                      |
|   Fetch Operator             |
|     limit:-1                 |
|     Select Operator [SEL_2]  |
|       Output:["_col0"]       |
|       TableScan [TS_0]       |
|         Output:["id"]        |
|                              |
+------------------------------+ {code}


was (Author: okumin):
I am just testing the repro query on my local machine.
{code:java}
explain select id from t1 where (case when month='2023-07' then false else true 
END); {code}
With CBO, the predicate is partially evaluated as `(month = '2023-07') is not 
true`.
{code:java}
+----------------------------------------------------+
|                      Explain                       |
+----------------------------------------------------+
| Plan optimized by CBO.                             |
|                                                    |
| Stage-0                                            |
|   Fetch Operator                                   |
|     limit:-1                                       |
|     Select Operator [SEL_2]                        |
|       Output:["_col0"]                             |
|       Filter Operator [FIL_4]                      |
|         predicate:(month = '2023-07') is not true  |
|         TableScan [TS_0]                           |
|           Output:["id"]                            |
|                                                    |
+----------------------------------------------------+ {code}
Without CBO, no predicate is pushed. I remember there is an optimizer to remove 
redundant predicates(PartitionPruner? I forgot).
{code:java}
+------------------------------+
|           Explain            |
+------------------------------+
| Stage-0                      |
|   Fetch Operator             |
|     limit:-1                 |
|     Select Operator [SEL_2]  |
|       Output:["_col0"]       |
|       TableScan [TS_0]       |
|         Output:["id"]        |
|                              |
+------------------------------+ {code}
 

> Data Inconsistency due to missing 'IS NOT? TRUE/FALSE' parsing in Partition 
> Filter Pruning
> ------------------------------------------------------------------------------------------
>
>                 Key: HIVE-28705
>                 URL: https://issues.apache.org/jira/browse/HIVE-28705
>             Project: Hive
>          Issue Type: Bug
>            Reporter: chiranjeevi
>            Assignee: Indhumathi Muthumurugesh
>            Priority: Major
>              Labels: pull-request-available
>
> create table t1(id string) partitioned by (month string);
> insert into t1 select '1','2020-12';
> set hive.cbo.enable=false;
> select id from t1 where (case when month='2023-07' then false else true END);
> -- output: 1
> set hive.cbo.enable=true;
> select id from t1 where (case when month='2023-07' then false else true END);
> -- ouput: \{no result}



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

Reply via email to