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

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

                Author: ASF GitHub Bot
            Created on: 01/Aug/22 21:39
            Start Date: 01/Aug/22 21:39
    Worklog Time Spent: 10m 
      Work Description: achennagiri commented on code in PR #3487:
URL: https://github.com/apache/hive/pull/3487#discussion_r934940068


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java:
##########
@@ -974,44 +972,40 @@ Pair<Boolean, String> canCBOHandleAst(ASTNode ast, QB qb, 
PreCboCtx cboCtx) {
    *         Query<br>
    *         2. Nested Subquery will return false for qbToChk.getIsQuery()
    */
-  private static String canHandleQbForCbo(QueryProperties queryProperties, 
HiveConf conf,
-      boolean topLevelQB, boolean verbose) {
-
-    if (!queryProperties.hasClusterBy() && !queryProperties.hasDistributeBy()
-        && !(queryProperties.hasSortBy() && queryProperties.hasLimit())
-        && !queryProperties.hasPTF() && !queryProperties.usesScript()
-        && queryProperties.isCBOSupportedLateralViews()) {
-      // Ok to run CBO.
-      return null;
-    }
-
+  private static String canHandleQbForCbo(QueryProperties queryProperties,
+                                          HiveConf conf, boolean topLevelQB) {
+    List reasons = new ArrayList();
     // Not ok to run CBO, build error message.
-    String msg = "";
-    if (verbose) {
-      if (queryProperties.hasClusterBy()) {
-        msg += "has cluster by; ";
-      }
-      if (queryProperties.hasDistributeBy()) {
-        msg += "has distribute by; ";
-      }
-      if (queryProperties.hasSortBy() && queryProperties.hasLimit()) {
-        msg += "has sort by with limit; ";
-      }
-      if (queryProperties.hasPTF()) {
-        msg += "has PTF; ";
-      }
-      if (queryProperties.usesScript()) {
-        msg += "uses scripts; ";
-      }
-      if (queryProperties.hasLateralViews()) {
-        msg += "has lateral views; ";
-      }
-      if (msg.isEmpty()) {
-        msg += "has some unspecified limitations; ";
-      }
-      msg = msg.substring(0, msg.length() - 2);
+    String errorMsg = "";
+    if (queryProperties.hasClusterBy()) {
+      errorMsg = "has cluster by";
+      reasons.add(errorMsg);
+    }
+    if (queryProperties.hasDistributeBy()) {
+      errorMsg = "has distribute by";
+      reasons.add(errorMsg);
+    }
+    if (queryProperties.hasSortBy() && queryProperties.hasLimit()) {
+      errorMsg = "has sort by with limit";
+      reasons.add(errorMsg);
+    }
+    if (queryProperties.hasPTF()) {
+      errorMsg = "has PTF";
+      reasons.add(errorMsg);
+    }
+    if (queryProperties.usesScript()) {
+      errorMsg = "uses scripts";
+      reasons.add(errorMsg);
+    }
+    if (queryProperties.hasLateralViews()) {
+      errorMsg = "has lateral views";
+      reasons.add(errorMsg);
+    }
+    if (!queryProperties.isCBOSupportedLateralViews()) {

Review Comment:
   Trying to keep the error messaging the same. If isCBOSupportedLateralViews() 
returns False, only then the error message will be "has some unspecified 
limitations".
   





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

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

> Remove unnecessary optimization in canHandleQbForCbo() method
> -------------------------------------------------------------
>
>                 Key: HIVE-26438
>                 URL: https://issues.apache.org/jira/browse/HIVE-26438
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Abhay
>            Assignee: Abhay
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> This ticket is an improvement on 
> https://issues.apache.org/jira/browse/HIVE-26426.  The canHandleQbForCbo() 
> checks whether Calcite handle the query or not and it returns null if the 
> query can be handled; non-null reason string if it cannot be. 
> But currently, it returns an empty string if INFO Log is not enabled. This is 
> probably a performance optimization that is not needed and can be simplified. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to