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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]