Repository: hive Updated Branches: refs/heads/master ef7c3963b -> 5131046ca
HIVE-21041: NPE, ParseException in getting schema from logical plan (Teddy Choi, reviewed by Jesus Camacho Rodriguez) Change-Id: Iff9d9b02f934ed800f932ff916a59288a896f169 Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/5131046c Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/5131046c Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/5131046c Branch: refs/heads/master Commit: 5131046ca795ecf958e4e24f163e6014588c2222 Parents: ef7c396 Author: Teddy Choi <[email protected]> Authored: Tue Dec 18 23:57:36 2018 +0900 Committer: Teddy Choi <[email protected]> Committed: Tue Dec 18 23:57:36 2018 +0900 ---------------------------------------------------------------------- .../test/resources/testconfiguration.properties | 1 + .../apache/hadoop/hive/ql/parse/ParseUtils.java | 22 +++++++++++-------- .../test/queries/clientpositive/get_splits_0.q | 3 +++ .../clientpositive/llap/get_splits_0.q.out | Bin 0 -> 916 bytes 4 files changed, 17 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/5131046c/itests/src/test/resources/testconfiguration.properties ---------------------------------------------------------------------- diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties index 01cad2a..18e4f7f 100644 --- a/itests/src/test/resources/testconfiguration.properties +++ b/itests/src/test/resources/testconfiguration.properties @@ -527,6 +527,7 @@ minillaplocal.query.files=\ external_jdbc_table_partition.q,\ external_jdbc_table_typeconversion.q,\ fullouter_mapjoin_1_optimized.q,\ + get_splits_0.q,\ groupby2.q,\ groupby_groupingset_bug.q,\ hybridgrace_hashjoin_1.q,\ http://git-wip-us.apache.org/repos/asf/hive/blob/5131046c/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java index be1c59f..07c65af 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java @@ -545,22 +545,26 @@ public final class ParseUtils { public static RelNode parseQuery(HiveConf conf, String viewQuery) throws SemanticException, IOException, ParseException { - return getAnalyzer(conf).genLogicalPlan(parse(viewQuery)); + final Context ctx = new Context(conf); + ctx.setIsLoadingMaterializedView(true); + final ASTNode ast = parse(viewQuery, ctx); + final CalcitePlanner analyzer = getAnalyzer(conf, ctx); + return analyzer.genLogicalPlan(ast); } public static List<FieldSchema> parseQueryAndGetSchema(HiveConf conf, String viewQuery) throws SemanticException, IOException, ParseException { - final CalcitePlanner analyzer = getAnalyzer(conf); - analyzer.genLogicalPlan(parse(viewQuery)); + final Context ctx = new Context(conf); + ctx.setIsLoadingMaterializedView(true); + final ASTNode ast = parse(viewQuery, ctx); + final CalcitePlanner analyzer = getAnalyzer(conf, ctx); + analyzer.genLogicalPlan(ast); return analyzer.getResultSchema(); } - private static CalcitePlanner getAnalyzer(HiveConf conf) throws SemanticException, IOException { - final QueryState qs = - new QueryState.Builder().withHiveConf(conf).build(); - CalcitePlanner analyzer = new CalcitePlanner(qs); - Context ctx = new Context(conf); - ctx.setIsLoadingMaterializedView(true); + private static CalcitePlanner getAnalyzer(HiveConf conf, Context ctx) throws SemanticException { + final QueryState qs = new QueryState.Builder().withHiveConf(conf).build(); + final CalcitePlanner analyzer = new CalcitePlanner(qs); analyzer.initCtx(ctx); analyzer.init(false); return analyzer; http://git-wip-us.apache.org/repos/asf/hive/blob/5131046c/ql/src/test/queries/clientpositive/get_splits_0.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/get_splits_0.q b/ql/src/test/queries/clientpositive/get_splits_0.q new file mode 100644 index 0000000..e585fda --- /dev/null +++ b/ql/src/test/queries/clientpositive/get_splits_0.q @@ -0,0 +1,3 @@ +--! qt:dataset:src +select get_splits("SELECT * FROM src WHERE value in (SELECT value FROM src)",0); +select get_splits("SELECT key AS `key 1`, value AS `value 1` FROM src",0); http://git-wip-us.apache.org/repos/asf/hive/blob/5131046c/ql/src/test/results/clientpositive/llap/get_splits_0.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/llap/get_splits_0.q.out b/ql/src/test/results/clientpositive/llap/get_splits_0.q.out new file mode 100644 index 0000000..e1ebe95 Binary files /dev/null and b/ql/src/test/results/clientpositive/llap/get_splits_0.q.out differ
