IMPALA-5524: Fixes NPE during planning with DISABLE_UNSAFE_SPILLS=1 This change will avoid a NPE during query planning under the following conditions: - DISABLE_UNSAFE_SPILLS is TRUE or 1 - All tables involved in the query have stats
Change-Id: Iccae7fdeaf0ade0b8728a7d249981c8270e8c327 Reviewed-on: http://gerrit.cloudera.org:8080/7219 Reviewed-by: Tim Armstrong <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/39e8cf31 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/39e8cf31 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/39e8cf31 Branch: refs/heads/master Commit: 39e8cf313f41acc1a70be4c12b67173bd156f029 Parents: 64fd011 Author: Vincent Tran <[email protected]> Authored: Fri Jun 16 21:22:07 2017 -0400 Committer: Impala Public Jenkins <[email protected]> Committed: Wed Jul 12 03:54:23 2017 +0000 ---------------------------------------------------------------------- .../java/org/apache/impala/service/Frontend.java | 1 + .../org/apache/impala/planner/PlannerTest.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/39e8cf31/fe/src/main/java/org/apache/impala/service/Frontend.java ---------------------------------------------------------------------- diff --git a/fe/src/main/java/org/apache/impala/service/Frontend.java b/fe/src/main/java/org/apache/impala/service/Frontend.java index 855a076..2c71a9b 100644 --- a/fe/src/main/java/org/apache/impala/service/Frontend.java +++ b/fe/src/main/java/org/apache/impala/service/Frontend.java @@ -1019,6 +1019,7 @@ public class Frontend { // or if all tables have stats. boolean disableSpilling = queryCtx.client_request.query_options.isDisable_unsafe_spills() + && queryCtx.isSetTables_missing_stats() && !queryCtx.tables_missing_stats.isEmpty() && !analysisResult.getAnalyzer().hasPlanHints(); queryCtx.setDisable_spilling(disableSpilling); http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/39e8cf31/fe/src/test/java/org/apache/impala/planner/PlannerTest.java ---------------------------------------------------------------------- diff --git a/fe/src/test/java/org/apache/impala/planner/PlannerTest.java b/fe/src/test/java/org/apache/impala/planner/PlannerTest.java index 4641d68..3b199f3 100644 --- a/fe/src/test/java/org/apache/impala/planner/PlannerTest.java +++ b/fe/src/test/java/org/apache/impala/planner/PlannerTest.java @@ -454,4 +454,23 @@ public class PlannerTest extends PlannerTestBase { options.setDefault_join_distribution_mode(TJoinDistributionMode.SHUFFLE); runPlannerTestFile("default-join-distr-mode-shuffle", options); } + + @Test + public void testComputeStatsDisableSpill() throws ImpalaException { + TQueryCtx queryCtx = TestUtils.createQueryContext(Catalog.DEFAULT_DB, + System.getProperty("user.name")); + TExecRequest requestWithDisableSpillOn = null; + // Setting up a table with computed stats + queryCtx.client_request.setStmt("compute stats functional.alltypes"); + queryCtx.client_request.query_options = defaultQueryOptions(); + StringBuilder explainBuilder = new StringBuilder(); + frontend_.createExecRequest(queryCtx, explainBuilder); + // Setting up an arbitrary query involving a table with stats. + queryCtx.client_request.setStmt("select * from functional.alltypes"); + // Setting disable_unsafe_spills = true to verify that it no longer + // throws a NPE with computed stats (IMPALA-5524) + queryCtx.client_request.query_options.setDisable_unsafe_spills(true); + requestWithDisableSpillOn = frontend_.createExecRequest(queryCtx, explainBuilder); + Assert.assertNotNull(requestWithDisableSpillOn); + } }
