zabetak commented on code in PR #6360:
URL: https://github.com/apache/hive/pull/6360#discussion_r2958952533


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java:
##########
@@ -461,16 +458,6 @@ public Frame decorrelateRel(Sort rel) {
             frame.corDefOutputs);
   }
 
-  /**
-   * Rewrites a {@link Values}.
-   *
-   * @param rel Values to be rewritten
-   */
-  public Frame decorrelateRel(Values rel) {
-    // There are no inputs, so rel does not need to be changed.
-    return null;
-  }
-

Review Comment:
   Are the following rules still relevant/necessary after we perform this 
change:
   
   * HiveRemoveEmptySingleRules.CORRELATE_LEFT_INSTANCE
   * HiveRemoveEmptySingleRules.CORRELATE_RIGHT_INSTANCE



##########
ql/src/test/queries/clientpositive/empty_result_correlate2.q:
##########
@@ -0,0 +1,22 @@
+set hive.support.concurrency=true;
+set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+-- To create a HiveValues operator before decorrelation automatic query 
rewrite with
+-- materialized views is used.
+-- All tables must be transactional to trigger automatic query rewrite.
+create table mv_source (any_col int) stored as orc TBLPROPERTIES 
('transactional'='true');
+create table t1 (a int, b int) stored as orc TBLPROPERTIES 
('transactional'='true');
+create table t2 (a int, b int) stored as orc TBLPROPERTIES 
('transactional'='true');
+
+-- At least one materialized view must exist.
+create materialized view any_mv as
+select any_col from mv_source where any_col > 20;
+
+-- Automatic query rewrite traverses the plan and recreates the HiveFilter 
using RelBuilder.
+-- If the condition is always false, it replaces the filter with HiveValues.
+explain cbo
+select * from t1 where 1 = 2
+union
+select * from t1
+where exists (select a from t2 where t1.a > 10)

Review Comment:
   Can you elaborate a bit on why the existing `HiveRemoveEmptySingleRules` are 
not helping in this case? 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to