Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ CommandProcessorResponse processLocalCmd(String cmd, CommandProcessor proc, CliS
console.printError("Failed with exception " + e.getClass().getName() + ":" + e.getMessage(),
"\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
throw new CommandProcessorException(1);
} finally {
} catch (RuntimeException e) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this change:

  1. The SimpleFetchOptimizer change disables caching for non-ACID tables, making FetchTask.execute() a no op. Rows are now fetched lazily via Driver.getResults() after qp.run(). So the exceptions that previously surfaced inside qp.run() now escapes as unchecked RunTimeException from the fetch loop.
  2. ProcessLocalCmd() only caught IOExceptions, so the RunTImeException bubbled up and never became a CommandProcessorException causing tests tests like, udf_assert_true.q, udf_assert_true2.q to fail.
  3. The fix adds a separate catch (RuntimeException e) that silently converts it to CommandProcessorException. It intentionally does not reprint the error since FetchTask.executeInner() already did that. Plus doing that will change .q.out file which i was trying to avoid.

throw new CommandProcessorException(1);
} finally {
qp.close();
ShimLoader.getHadoopShims()
.setHadoopSessionContext(String.format(USER_ID, ss.getSessionId(), ss.getUserName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.apache.hadoop.hive.ql.exec.TaskFactory;
import org.apache.hadoop.hive.ql.exec.Utilities;
import org.apache.hadoop.hive.ql.hooks.ReadEntity;
import org.apache.hadoop.hive.ql.io.AcidUtils;
import org.apache.hadoop.hive.ql.io.ContentSummaryInputFormat;
import org.apache.hadoop.hive.ql.io.HiveInputFormat;
import org.apache.hadoop.hive.ql.metadata.HiveException;
Expand Down Expand Up @@ -144,8 +145,14 @@ private FetchTask optimize(ParseContext pctx, String alias, TableScanOperator so
if (fetch != null && checkThreshold(fetch, limit, pctx)) {
FetchWork fetchWork = fetch.convertToWork();
FetchTask fetchTask = (FetchTask) TaskFactory.get(fetchWork);
fetchTask.setCachingEnabled(HiveConf.getBoolVar(pctx.getConf(),
HiveConf.ConfVars.HIVE_FETCH_TASK_CACHING));
boolean cachingEnabled = HiveConf.getBoolVar(pctx.getConf(),
HiveConf.ConfVars.HIVE_FETCH_TASK_CACHING);
if (cachingEnabled && !AcidUtils.isTransactionalTable(fetch.table)) {
LOG.debug("Fetch task caching is enabled but table {} is not transactional. " +
"Caching is only supported for ACID tables. Disabling.", fetch.table.getCompleteName());
cachingEnabled = false;
}
fetchTask.setCachingEnabled(cachingEnabled);
fetchWork.setSink(fetch.completed(pctx, fetchWork));
fetchWork.setSource(source);
fetchWork.setLimit(limit);
Expand Down
Loading