kasakrisz commented on a change in pull request #1706:
URL: https://github.com/apache/hive/pull/1706#discussion_r540858913



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
##########
@@ -2349,6 +2362,50 @@ private RelNode 
applyMaterializedViewRewriting(RelOptPlanner planner, RelNode ba
       return basePlan;
     }
 
+    private RelOptMaterialization 
copyMaterializationToNewCluster(RelOptCluster optCluster, RelOptMaterialization 
materialization) {
+      final RelNode viewScan = materialization.tableRel;
+      final RelNode newViewScan = HiveMaterializedViewUtils.copyNodeNewCluster(
+              optCluster, viewScan);
+      return new RelOptMaterialization(newViewScan, materialization.queryRel, 
null,
+              materialization.qualifiedTableName);
+    }
+
+    private boolean isMaterializedViewRewritingByTextEnabled() {
+      return 
conf.getBoolVar(ConfVars.HIVE_MATERIALIZED_VIEW_ENABLE_AUTO_REWRITING_QUERY_TEXT)
 &&
+              mvRebuildMode == MaterializationRebuildMode.NONE &&
+              !getQB().isMaterializedView() && 
!ctx.isLoadingMaterializedView() && !getQB().isCTAS() &&
+              getQB().getIsQuery() &&
+              getQB().hasTableDefined();
+    }
+
+    private RelNode applyMaterializedViewRewritingByText(RelNode 
calciteGenPlan, RelOptCluster optCluster) {
+      unparseTranslator.applyTranslations(ctx.getTokenRewriteStream(), 
EXPANDED_QUERY_TOKEN_REWRITE_PROGRAM);
+      String expandedQueryText = ctx.getTokenRewriteStream()
+              .toString(EXPANDED_QUERY_TOKEN_REWRITE_PROGRAM, 
ast.getTokenStartIndex(), ast.getTokenStopIndex());
+      try {
+        List<RelOptMaterialization> relOptMaterializationList = 
db.getMaterialization(
+                expandedQueryText, getTablesUsed(calciteGenPlan), getTxnMgr());
+        for (RelOptMaterialization relOptMaterialization : 
relOptMaterializationList) {
+          try {
+            Table hiveTableMD = extractTable(relOptMaterialization);
+            if (db.validateMaterializedViewsFromRegistry(

Review comment:
       added check, and tests




----------------------------------------------------------------
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.

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