[ 
https://issues.apache.org/jira/browse/HIVE-25941?focusedWorklogId=732259&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-732259
 ]

ASF GitHub Bot logged work on HIVE-25941:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Feb/22 12:36
            Start Date: 24/Feb/22 12:36
    Worklog Time Spent: 10m 
      Work Description: kasakrisz commented on a change in pull request #3014:
URL: https://github.com/apache/hive/pull/3014#discussion_r813836616



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/metadata/MaterializedViewsCache.java
##########
@@ -205,4 +212,52 @@ HiveRelOptMaterialization get(String dbName, String 
viewName) {
   public boolean isEmpty() {
     return materializedViews.isEmpty();
   }
+
+
+  private static class ASTKey {
+    private final ASTNode root;
+
+    public ASTKey(ASTNode root) {
+      this.root = root;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      ASTKey that = (ASTKey) o;
+      return equals(root, that.root);
+    }
+
+    private boolean equals(ASTNode astNode1, ASTNode astNode2) {
+      if (!(astNode1.getType() == astNode2.getType() &&
+              astNode1.getText().equals(astNode2.getText()) &&
+              astNode1.getChildCount() == astNode2.getChildCount())) {
+        return false;
+      }
+
+      for (int i = 0; i < astNode1.getChildCount(); ++i) {
+        if (!equals((ASTNode) astNode1.getChild(i), (ASTNode) 
astNode2.getChild(i))) {
+          return false;
+        }
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      return hashcode(root);
+    }
+
+    private int hashcode(ASTNode node) {
+      int result = Objects.hash(node.getType(), node.getText());

Review comment:
       `ASTNode` does not contains the whole query string just small tokens 
extracted by the parser. If only a portion of the definition should be used for 
computing the hash code the limit could be the depth of the AST.
   I would do it in a follow-up patch if this turn to be a bottleneck.




-- 
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-unsubscr...@hive.apache.org

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 732259)
    Time Spent: 0.5h  (was: 20m)

> Long compilation time of complex query due to analysis for materialized view 
> rewrite
> ------------------------------------------------------------------------------------
>
>                 Key: HIVE-25941
>                 URL: https://issues.apache.org/jira/browse/HIVE-25941
>             Project: Hive
>          Issue Type: Bug
>          Components: Materialized views
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: sample.png
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> When compiling query the optimizer tries to rewrite the query plan or 
> subtrees of the plan to use materialized view scans.
> If
> {code}
> set hive.materializedview.rewriting.sql.subquery=false;
> {code}
> the compilation succeed in less then 10 sec otherwise it takes several 
> minutes (~ 5min) depending on the hardware.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to