You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by za...@apache.org on 2024/07/17 12:54:59 UTC

(hive) branch master updated: HIVE-28314: Support non-boolean WHERE conditions in CBO (Soumyakanti Das reviewed by Stamatis Zampetakis)

This is an automated email from the ASF dual-hosted git repository.

zabetak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new b18d5732b4f HIVE-28314: Support non-boolean WHERE conditions in CBO (Soumyakanti Das reviewed by Stamatis Zampetakis)
b18d5732b4f is described below

commit b18d5732b4f309fdc3b8226847c9c1ebcd2476fd
Author: Soumyakanti Das <so...@gmail.com>
AuthorDate: Fri Jun 7 16:12:54 2024 -0700

    HIVE-28314: Support non-boolean WHERE conditions in CBO (Soumyakanti Das reviewed by Stamatis Zampetakis)
    
    Close apache/hive#5291
---
 .../test/queries/positive/delete_iceberg_mixed.q   |   2 +
 .../results/positive/delete_iceberg_mixed.q.out    |   2 +
 .../calcite/CalciteSemanticException.java          |   2 +-
 .../hadoop/hive/ql/parse/CalcitePlanner.java       |  18 +-
 .../queries/clientpositive/annotate_stats_filter.q |   2 +
 .../test/queries/clientpositive/filter_literals.q  |  73 ++++++
 .../llap/annotate_stats_filter.q.out               |  12 +
 .../clientpositive/llap/filter_literals.q.out      | 281 +++++++++++++++++++++
 .../clientpositive/llap/vector_empty_where.q.out   |  16 +-
 9 files changed, 387 insertions(+), 21 deletions(-)

diff --git a/iceberg/iceberg-handler/src/test/queries/positive/delete_iceberg_mixed.q b/iceberg/iceberg-handler/src/test/queries/positive/delete_iceberg_mixed.q
index bbad2f380e3..cd85d87af29 100644
--- a/iceberg/iceberg-handler/src/test/queries/positive/delete_iceberg_mixed.q
+++ b/iceberg/iceberg-handler/src/test/queries/positive/delete_iceberg_mixed.q
@@ -6,6 +6,8 @@
 --! qt:replace:/("removed-files-size":")\d+/$1#FileSize#/
 
 -- create an unpartitioned table with skip delete data set to false
+set hive.cbo.fallback.strategy=NEVER;
+
  create table ice01 (id int, name string) Stored by Iceberg stored as ORC
  TBLPROPERTIES('format-version'='2');
 
diff --git a/iceberg/iceberg-handler/src/test/results/positive/delete_iceberg_mixed.q.out b/iceberg/iceberg-handler/src/test/results/positive/delete_iceberg_mixed.q.out
index 4599a458520..547f1458b08 100644
--- a/iceberg/iceberg-handler/src/test/results/positive/delete_iceberg_mixed.q.out
+++ b/iceberg/iceberg-handler/src/test/results/positive/delete_iceberg_mixed.q.out
@@ -167,10 +167,12 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
 {"added-data-files":"1","deleted-data-files":"1","added-records":"3","deleted-records":"9","added-files-size":"#FileSize#","removed-files-size":"#FileSize#","changed-partition-count":"1","total-records":"3","total-files-size":"#FileSize#","total-data-files":"1","total-delete-files":"1","total-position-deletes":"2","total-equality-deletes":"0"}
 PREHOOK: query: delete from ice01 where null
 PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
 PREHOOK: Input: default@ice01
 PREHOOK: Output: default@ice01
 POSTHOOK: query: delete from ice01 where null
 POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
 POSTHOOK: Input: default@ice01
 POSTHOOK: Output: default@ice01
 PREHOOK: query: select * from ice01
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/CalciteSemanticException.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/CalciteSemanticException.java
index b675c15bf16..a73aa3ba1e7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/CalciteSemanticException.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/CalciteSemanticException.java
@@ -30,7 +30,7 @@ public class CalciteSemanticException extends SemanticException {
   private static final long serialVersionUID = 1L;
 
   public enum UnsupportedFeature {
-    Distinct_without_an_aggregation, Duplicates_in_RR, Filter_expression_with_non_boolean_return_type,
+    Distinct_without_an_aggregation, Duplicates_in_RR,
     Having_clause_without_any_groupby, Invalid_column_reference, Invalid_decimal,
     Less_than_equal_greater_than, Others, Same_name_in_multiple_expressions,
     Schema_less_table, Select_alias_in_having_clause, Select_transform, Subquery,
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
index 02b0d59cb8d..e4bd4bfcb0f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
@@ -3199,18 +3199,12 @@ public class CalcitePlanner extends SemanticAnalyzer {
     }
 
     private RelNode genFilterRelNode(RexNode filterExpression, RelNode srcRel,
-        ImmutableMap<String, Integer> outerNameToPosMap, RowResolver outerRR) throws SemanticException {
-      if (RexUtil.isLiteral(filterExpression, false)
-          && filterExpression.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
-        // queries like select * from t1 where 'foo';
-        // Calcite's rule PushFilterThroughProject chokes on it. Arguably, we
-        // can insert a cast to
-        // boolean in such cases, but since Postgres, Oracle and MS SQL server
-        // fail on compile time
-        // for such queries, its an arcane corner case, not worth of adding that
-        // complexity.
-        throw new CalciteSemanticException("Filter expression with non-boolean return type.",
-            UnsupportedFeature.Filter_expression_with_non_boolean_return_type);
+        ImmutableMap<String, Integer> outerNameToPosMap, RowResolver outerRR) {
+      if (filterExpression.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
+        // Cast filterExpression with BOOLEAN if it is not BOOLEAN
+        RelDataType booleanType = srcRel.getCluster().getTypeFactory().createSqlType(SqlTypeName.BOOLEAN);
+        filterExpression = srcRel.getCluster().getRexBuilder()
+            .makeCast(booleanType, filterExpression);
       }
       final ImmutableMap<String, Integer> hiveColNameCalcitePosMap =
           this.relToHiveColNameCalcitePosMap.get(srcRel);
diff --git a/ql/src/test/queries/clientpositive/annotate_stats_filter.q b/ql/src/test/queries/clientpositive/annotate_stats_filter.q
index a352a77bc26..a110ea6def8 100644
--- a/ql/src/test/queries/clientpositive/annotate_stats_filter.q
+++ b/ql/src/test/queries/clientpositive/annotate_stats_filter.q
@@ -1,5 +1,6 @@
 set hive.mapred.mode=nonstrict;
 set hive.stats.fetch.column.stats=true;
+set hive.cbo.fallback.strategy=NEVER;
 
 create table if not exists loc_staging (
   state string,
@@ -55,6 +56,7 @@ explain select * from loc_orc where !true;
 -- numRows: 8 rawDataSize: 804
 explain select * from loc_orc where true;
 -- numRows: 8 rawDataSize: 804
+explain cbo select * from loc_orc where 'foo';
 explain select * from loc_orc where 'foo';
 -- numRows: 8 rawDataSize: 804
 explain select * from loc_orc where true = true;
diff --git a/ql/src/test/queries/clientpositive/filter_literals.q b/ql/src/test/queries/clientpositive/filter_literals.q
new file mode 100644
index 00000000000..9bc38333e81
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/filter_literals.q
@@ -0,0 +1,73 @@
+--! qt:dataset:alltypesorc
+set hive.cbo.fallback.strategy=NEVER;
+
+-- test CBO explain plans
+explain cbo
+select * from alltypesorc where 'foo';
+
+explain cbo
+select * from alltypesorc where 'foo' and 'bar';
+
+explain cbo
+select * from alltypesorc where 'foo' or 'bar';
+
+explain cbo
+select * from alltypesorc where 'foo' and cint in (2, 3);
+
+explain cbo 
+select * from alltypesorc where not 'foo';
+
+explain cbo
+select * from alltypesorc where 1;
+
+explain cbo
+select * from alltypesorc where 1 and 2;
+
+explain cbo
+select * from alltypesorc where not 1;
+
+-- test results from CBO and non-CBO paths
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where 'foo';
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where 'foo';
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where 'true';
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where 'true';
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where 'false';
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where 'false';
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where true;
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where true;
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where false;
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where false;
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where 1;
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where 1;
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where 0;
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where 0;
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where -1;
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where -1;
+
+set hive.cbo.enable=true;
+select count(*) from alltypesorc where null;
+set hive.cbo.enable=false;
+select count(*) from alltypesorc where null;
diff --git a/ql/src/test/results/clientpositive/llap/annotate_stats_filter.q.out b/ql/src/test/results/clientpositive/llap/annotate_stats_filter.q.out
index 8e1e98897db..41f21f625b8 100644
--- a/ql/src/test/results/clientpositive/llap/annotate_stats_filter.q.out
+++ b/ql/src/test/results/clientpositive/llap/annotate_stats_filter.q.out
@@ -357,6 +357,18 @@ STAGE PLANS:
             outputColumnNames: _col0, _col1, _col2, _col3
             ListSink
 
+PREHOOK: query: explain cbo select * from loc_orc where 'foo'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@loc_orc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo select * from loc_orc where 'foo'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@loc_orc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(state=[$0], locid=[$1], zip=[$2], year=[$3])
+  HiveTableScan(table=[[default, loc_orc]], table:alias=[loc_orc])
+
 PREHOOK: query: explain select * from loc_orc where 'foo'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@loc_orc
diff --git a/ql/src/test/results/clientpositive/llap/filter_literals.q.out b/ql/src/test/results/clientpositive/llap/filter_literals.q.out
new file mode 100644
index 00000000000..bde7280d64c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/filter_literals.q.out
@@ -0,0 +1,281 @@
+PREHOOK: query: explain cbo
+select * from alltypesorc where 'foo'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where 'foo'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ctinyint=[$0], csmallint=[$1], cint=[$2], cbigint=[$3], cfloat=[$4], cdouble=[$5], cstring1=[$6], cstring2=[$7], ctimestamp1=[$8], ctimestamp2=[$9], cboolean1=[$10], cboolean2=[$11])
+  HiveTableScan(table=[[default, alltypesorc]], table:alias=[alltypesorc])
+
+PREHOOK: query: explain cbo
+select * from alltypesorc where 'foo' and 'bar'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where 'foo' and 'bar'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ctinyint=[$0], csmallint=[$1], cint=[$2], cbigint=[$3], cfloat=[$4], cdouble=[$5], cstring1=[$6], cstring2=[$7], ctimestamp1=[$8], ctimestamp2=[$9], cboolean1=[$10], cboolean2=[$11])
+  HiveTableScan(table=[[default, alltypesorc]], table:alias=[alltypesorc])
+
+PREHOOK: query: explain cbo
+select * from alltypesorc where 'foo' or 'bar'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where 'foo' or 'bar'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ctinyint=[$0], csmallint=[$1], cint=[$2], cbigint=[$3], cfloat=[$4], cdouble=[$5], cstring1=[$6], cstring2=[$7], ctimestamp1=[$8], ctimestamp2=[$9], cboolean1=[$10], cboolean2=[$11])
+  HiveTableScan(table=[[default, alltypesorc]], table:alias=[alltypesorc])
+
+PREHOOK: query: explain cbo
+select * from alltypesorc where 'foo' and cint in (2, 3)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where 'foo' and cint in (2, 3)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ctinyint=[$0], csmallint=[$1], cint=[$2], cbigint=[$3], cfloat=[$4], cdouble=[$5], cstring1=[$6], cstring2=[$7], ctimestamp1=[$8], ctimestamp2=[$9], cboolean1=[$10], cboolean2=[$11])
+  HiveFilter(condition=[IN($2, 2, 3)])
+    HiveTableScan(table=[[default, alltypesorc]], table:alias=[alltypesorc])
+
+PREHOOK: query: explain cbo 
+select * from alltypesorc where not 'foo'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo 
+select * from alltypesorc where not 'foo'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveValues(tuples=[[]])
+
+PREHOOK: query: explain cbo
+select * from alltypesorc where 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ctinyint=[$0], csmallint=[$1], cint=[$2], cbigint=[$3], cfloat=[$4], cdouble=[$5], cstring1=[$6], cstring2=[$7], ctimestamp1=[$8], ctimestamp2=[$9], cboolean1=[$10], cboolean2=[$11])
+  HiveTableScan(table=[[default, alltypesorc]], table:alias=[alltypesorc])
+
+PREHOOK: query: explain cbo
+select * from alltypesorc where 1 and 2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where 1 and 2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ctinyint=[$0], csmallint=[$1], cint=[$2], cbigint=[$3], cfloat=[$4], cdouble=[$5], cstring1=[$6], cstring2=[$7], ctimestamp1=[$8], ctimestamp2=[$9], cboolean1=[$10], cboolean2=[$11])
+  HiveTableScan(table=[[default, alltypesorc]], table:alias=[alltypesorc])
+
+PREHOOK: query: explain cbo
+select * from alltypesorc where not 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo
+select * from alltypesorc where not 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveValues(tuples=[[]])
+
+PREHOOK: query: select count(*) from alltypesorc where 'foo'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 'foo'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where 'foo'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 'foo'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where 'true'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 'true'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where 'true'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 'true'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where 'false'
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 'false'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where 'false'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 'false'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where true
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where true
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where true
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where true
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where false
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where false
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where false
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where false
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where 0
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where 0
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where 0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where -1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where -1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where -1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where -1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+12288
+PREHOOK: query: select count(*) from alltypesorc where null
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where null
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
+PREHOOK: query: select count(*) from alltypesorc where null
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from alltypesorc where null
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+0
diff --git a/ql/src/test/results/clientpositive/llap/vector_empty_where.q.out b/ql/src/test/results/clientpositive/llap/vector_empty_where.q.out
index ea480f0ba03..0d64eeb15d1 100644
--- a/ql/src/test/results/clientpositive/llap/vector_empty_where.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_empty_where.q.out
@@ -203,7 +203,7 @@ STAGE PLANS:
             Map Operator Tree:
                 TableScan
                   alias: alltypesorc
-                  filterExpr: UDFToBoolean(cint) (type: boolean)
+                  filterExpr: (cint <> 0) (type: boolean)
                   Statistics: Num rows: 12288 Data size: 36696 Basic stats: COMPLETE Column stats: COMPLETE
                   TableScan Vectorization:
                       native: true
@@ -211,9 +211,9 @@ STAGE PLANS:
                     Filter Vectorization:
                         className: VectorFilterOperator
                         native: true
-                        predicateExpression: SelectColumnIsTrue(col 14:boolean)(children: CastLongToBooleanViaLongToLong(col 2:int) -> 14:boolean)
-                    predicate: UDFToBoolean(cint) (type: boolean)
-                    Statistics: Num rows: 6144 Data size: 18348 Basic stats: COMPLETE Column stats: COMPLETE
+                        predicateExpression: FilterLongColNotEqualLongScalar(col 2:int, val 0)
+                    predicate: (cint <> 0) (type: boolean)
+                    Statistics: Num rows: 12288 Data size: 36696 Basic stats: COMPLETE Column stats: COMPLETE
                     Group By Operator
                       Group By Vectorization:
                           className: VectorGroupByOperator
@@ -223,10 +223,10 @@ STAGE PLANS:
                           vectorProcessingMode: HASH
                           projectedOutputColumnNums: []
                       keys: cint (type: int)
-                      minReductionHashAggr: 0.4
+                      minReductionHashAggr: 0.5031738
                       mode: hash
                       outputColumnNames: _col0
-                      Statistics: Num rows: 6104 Data size: 18228 Basic stats: COMPLETE Column stats: COMPLETE
+                      Statistics: Num rows: 6105 Data size: 18232 Basic stats: COMPLETE Column stats: COMPLETE
                       Reduce Output Operator
                         key expressions: _col0 (type: int)
                         null sort order: z
@@ -236,7 +236,7 @@ STAGE PLANS:
                             className: VectorReduceSinkLongOperator
                             native: true
                             nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
-                        Statistics: Num rows: 6104 Data size: 18228 Basic stats: COMPLETE Column stats: COMPLETE
+                        Statistics: Num rows: 6105 Data size: 18232 Basic stats: COMPLETE Column stats: COMPLETE
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -268,7 +268,7 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int)
                 mode: mergepartial
                 outputColumnNames: _col0
-                Statistics: Num rows: 6104 Data size: 18228 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 6105 Data size: 18232 Basic stats: COMPLETE Column stats: COMPLETE
                 Group By Operator
                   aggregations: count(_col0)
                   Group By Vectorization: