You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/02/23 15:22:25 UTC

[GitHub] [hive] asolimando commented on a change in pull request #3033: HIVE-25953: Drop HiveRelMdPredicates::getPredicates(Join...) to use that of RelMdPredicates

asolimando commented on a change in pull request #3033:
URL: https://github.com/apache/hive/pull/3033#discussion_r813007732



##########
File path: ql/src/test/results/clientpositive/llap/subquery_scalar.q.out
##########
@@ -491,25 +484,25 @@ STAGE PLANS:
                 aggregations: count(VALUE._col0)
                 mode: mergepartial
                 outputColumnNames: _col0
-                Statistics: Num rows: 1 Data size: 196 Basic stats: COMPLETE Column stats: NONE
-                Limit
-                  Number of rows: 0
-                  Statistics: Num rows: 0 Data size: 0 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE
+                Filter Operator
+                  predicate: sq_count_check(_col0) (type: boolean)
+                  Statistics: Num rows: 1 Data size: 192 Basic stats: COMPLETE Column stats: NONE

Review comment:
       `HiveSortLimit(fetch=[0])` is introduced when `HiveMergeFilterRule` is invoked here:
   
   ```
   HiveFilter(condition=[false])
     HiveFilter(condition=[sq_count_check($0)])
       HiveAggregate(group=[{}], cnt=[COUNT()])
         HiveProject(p_name=[null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"])
           HiveFilter(condition=[IS NULL($1)])
             HiveTableScan(table=[[default, part_null_n1]], table:alias=[part_null_n1])
   ```
   
   The empty filter is rewritten by `HiveRelBuilder` as a LIMIT(0) expression (see [HiveRelBuilder.java#L133](https://github.com/apache/hive/blob/1c3ecf95f94a0329626a9fe46670586e7767f014/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelBuilder.java#L133)).
   
   The "false" predicate is not pushed transitively in this case for the Calcite implementation, so this transformation never happens, we are left with what is the original plan after decorrelation (for that specific subtree):
   
   ```
   2022-02-22T08:29:38,455 DEBUG [6a4314fb-ef37-46d8-8331-338fff02f1df main] parse.CalcitePlanner: Plan after decorrelation:
   HiveProject(p_partkey=[$0], p_name=[$1], p_mfgr=[$2], p_brand=[$3], p_type=[$4], p_size=[$5], p_container=[$6], p_retailprice=[$7], p_comment=
   [$8])
     HiveProject(p_partkey=[$0], p_name=[$1], p_mfgr=[$2], p_brand=[$3], p_type=[$4], p_size=[$5], p_container=[$6], p_retailprice=[$7], p_commen
   t=[$8], BLOCK__OFFSET__INSIDE__FILE=[$9], INPUT__FILE__NAME=[$10], ROW__ID=[$11], ROW__IS__DELETED=[$12])
       HiveFilter(condition=[=($1, $14)])
         HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
           HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
             HiveTableScan(table=[[default, part]], table:alias=[part])
             HiveFilter(condition=[sq_count_check($0)])
               HiveAggregate(group=[{}], cnt=[COUNT()])
                 HiveProject(p_name=[$1])
                   HiveFilter(condition=[IS NULL($1)])
                     HiveTableScan(table=[[default, part_null_n1]], table:alias=[part_null_n1])
           HiveProject(p_name=[$1])
             HiveFilter(condition=[IS NULL($1)])
               HiveTableScan(table=[[default, part_null_n1]], table:alias=[part_null_n1])
   ```
   
   `false` predicate is not inferred in Calcite, which does not support "non field predicates" (see [HiveRelMdPredicates.java#L439](https://github.com/apache/hive/blob/1c3ecf95f94a0329626a9fe46670586e7767f014/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdPredicates.java#L439)), which are predicates without field reference in it.
   
   I will see if I can craft a similar query for Calcite and file an improvement ticket to support such predicates without field reference.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org