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

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

                Author: ASF GitHub Bot
            Created on: 15/Dec/21 18:00
            Start Date: 15/Dec/21 18:00
    Worklog Time Spent: 10m 
      Work Description: zabetak commented on a change in pull request #2865:
URL: https://github.com/apache/hive/pull/2865#discussion_r769864327



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecDriver.java
##########
@@ -56,73 +58,92 @@
  * Covers the IDriver interface, handles query re-execution; and asks clear 
questions from the underlying re-execution plugins.
  */
 public class ReExecDriver implements IDriver {
+  private static final Logger LOG = 
LoggerFactory.getLogger(ReExecDriver.class);
+  private static final SessionState.LogHelper CONSOLE = new 
SessionState.LogHelper(LOG);
 
-  private class HandleReOptimizationExplain implements 
HiveSemanticAnalyzerHook {
-
-    @Override
-    public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode 
ast) throws SemanticException {
-      if (ast.getType() == HiveParser.TOK_EXPLAIN) {
-        int childCount = ast.getChildCount();
-        for (int i = 1; i < childCount; i++) {
-          if (ast.getChild(i).getType() == HiveParser.KW_REOPTIMIZATION) {
-            explainReOptimization = true;
-            ast.deleteChild(i);
-            break;
-          }
-        }
-        if (explainReOptimization && firstExecution()) {
-          Tree execTree = ast.getChild(0);
-          execTree.setParent(ast.getParent());
-          ast.getParent().setChild(0, execTree);
-          return (ASTNode) execTree;
-        }
-      }
-      return ast;
-    }
-
-    @Override
-    public void postAnalyze(HiveSemanticAnalyzerHookContext context, 
List<Task<?>> rootTasks)
-        throws SemanticException {
-    }
-  }
+  private final Driver coreDriver;
+  private final QueryState queryState;
+  private final List<IReExecutionPlugin> plugins;
 
-  private static final Logger LOG = 
LoggerFactory.getLogger(ReExecDriver.class);
   private boolean explainReOptimization;
-  private Driver coreDriver;
-  private QueryState queryState;
   private String currentQuery;
   private int executionIndex;
 
-  private ArrayList<IReExecutionPlugin> plugins;
+  public ReExecDriver(QueryState queryState, QueryInfo queryInfo, 
List<IReExecutionPlugin> plugins) {
+    this.queryState = queryState;
+    this.coreDriver = new Driver(queryState, queryInfo, null);
+    this.plugins = plugins;
 
-  @Override
-  public HiveConf getConf() {
-    return queryState.getConf();
+    coreDriver.getHookRunner().addSemanticAnalyzerHook(new 
HandleReOptimizationExplain());
+    plugins.forEach(p -> p.initialize(coreDriver));
+  }
+
+  @VisibleForTesting
+  public int compile(String command, boolean resetTaskIds) {
+    return coreDriver.compile(command, resetTaskIds);
   }
 
   private boolean firstExecution() {
     return executionIndex == 0;
   }
 
-  public ReExecDriver(QueryState queryState, QueryInfo queryInfo, 
ArrayList<IReExecutionPlugin> plugins) {
-    this.queryState = queryState;
-    coreDriver = new Driver(queryState, queryInfo, null);
-    coreDriver.getHookRunner().addSemanticAnalyzerHook(new 
HandleReOptimizationExplain());
-    this.plugins = plugins;
-
-    for (IReExecutionPlugin p : plugins) {
-      p.initialize(coreDriver);
+  private void checkHookConfig() throws CommandProcessorException {
+    String strategies = 
coreDriver.getConf().getVar(ConfVars.HIVE_QUERY_REEXECUTION_STRATEGIES);
+    CBOFallbackStrategy fallbackStrategy =
+        
CBOFallbackStrategy.valueOf(coreDriver.getConf().getVar(ConfVars.HIVE_CBO_FALLBACK_STRATEGY));
+    if (fallbackStrategy.allowsRetry() &&
+        (strategies == null || 
!Arrays.stream(strategies.split(",")).anyMatch("recompile_without_cbo"::equals)))
 {
+      String errorMsg = "Invalid configuration. If fallbackStrategy is set to 
" + fallbackStrategy.name() + " then " +
+          ConfVars.HIVE_QUERY_REEXECUTION_STRATEGIES.varname + " should 
contain 'recompile_without_cbo'";
+      CONSOLE.printError(errorMsg);
+      throw new CommandProcessorException(errorMsg);

Review comment:
       It might not be necessary to add this check if we change the way these 
properties interact with each other. For instance, we could drop/replace 
`hive.cbo.fallback.strategy`  with an alternative that fine tunes the 
recompilation hook.
   
   This is another element that points that keeping both as they are right now 
complicates code and configuration by end users.




-- 
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: 696789)
    Time Spent: 5.5h  (was: 5h 20m)

> Multi Insert query fails on CBO path 
> -------------------------------------
>
>                 Key: HIVE-25792
>                 URL: https://issues.apache.org/jira/browse/HIVE-25792
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Assignee: Peter Vary
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 5.5h
>  Remaining Estimate: 0h
>
> {code}
> set hive.cbo.enable=true;
> drop table if exists aa1;
> drop table if exists bb1;
> drop table if exists cc1;
> drop table if exists dd1;
> drop table if exists ee1;
> drop table if exists ff1;
> create table aa1 ( stf_id string);
> create table bb1 ( stf_id string);
> create table cc1 ( stf_id string);
> create table ff1 ( x string);
> explain
> from ff1 as a join cc1 as b 
> insert overwrite table aa1 select   stf_id GROUP BY b.stf_id
> insert overwrite table bb1 select b.stf_id GROUP BY b.stf_id
> ;
> {code}



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

Reply via email to