[ https://issues.apache.org/jira/browse/HIVE-24274?focusedWorklogId=522744&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-522744 ]
ASF GitHub Bot logged work on HIVE-24274: ----------------------------------------- Author: ASF GitHub Bot Created on: 10/Dec/20 14:25 Start Date: 10/Dec/20 14:25 Worklog Time Spent: 10m Work Description: kasakrisz commented on a change in pull request #1706: URL: https://github.com/apache/hive/pull/1706#discussion_r540209741 ########## File path: ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java ########## @@ -345,9 +345,19 @@ import javax.sql.DataSource; +import static java.util.Collections.singletonList; +import static org.apache.hadoop.hive.ql.optimizer.calcite.rules.views.HiveMaterializedViewUtils.extractTable; + public class CalcitePlanner extends SemanticAnalyzer { + /** + * {@link org.antlr.runtime.TokenRewriteStream} offers the opportunity of multiple rewrites of the same + * input text (in our case the sql query text). These rewrites are called programs and identified by a string. + * EXPANDED_QUERY_TOKEN_REWRITE_PROGRAM is for identifying the program which replaces all identifiers in the + * query with fully qualified identifiers. + */ + public static final String EXPANDED_QUERY_TOKEN_REWRITE_PROGRAM = "EXPANDED_QUERY_PROGRAM"; Review comment: done ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 522744) Time Spent: 1h 40m (was: 1.5h) > Implement Query Text based MaterializedView rewrite > --------------------------------------------------- > > Key: HIVE-24274 > URL: https://issues.apache.org/jira/browse/HIVE-24274 > Project: Hive > Issue Type: Improvement > Reporter: Krisztian Kasa > Assignee: Krisztian Kasa > Priority: Major > Labels: pull-request-available > Time Spent: 1h 40m > Remaining Estimate: 0h > > Besides the way queries are currently rewritten to use materialized views in > Hive this project provides an alternative: > Compare the query text with the materialized views query text stored. If we > found a match the original query's logical plan can be replaced by a scan on > the materialized view. > - Only materialized views which are enabled to rewrite can participate > - Use existing *HiveMaterializedViewsRegistry* through *Hive* object by > adding a lookup method by query text. > - There might be more than one materialized views which have the same query > text. In this case chose the first valid one. > - Validation can be done by calling > *Hive.validateMaterializedViewsFromRegistry()* > - The scope of this first patch is rewriting queries which entire text can be > matched only. > - Use the expanded query text (fully qualified column and table names) for > comparing -- This message was sent by Atlassian Jira (v8.3.4#803005)