Repository: hive
Updated Branches:
  refs/heads/branch-3 1ea6e49cf -> 86009a0d9


HIVE-21041: NPE, ParseException in getting schema from logical plan (Teddy 
Choi, reviewed by Jesus Camacho Rodriguez)

Change-Id: Iecdee8ddeea2ca3f862b16b1641569f027a12fbb


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/86009a0d
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/86009a0d
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/86009a0d

Branch: refs/heads/branch-3
Commit: 86009a0d9af52bfde21299eaea8e8b824e489e33
Parents: 1ea6e49
Author: Teddy Choi <[email protected]>
Authored: Tue Dec 18 23:59:52 2018 +0900
Committer: Teddy Choi <[email protected]>
Committed: Tue Dec 18 23:59:52 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/86009a0d/itests/src/test/resources/testconfiguration.properties
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/testconfiguration.properties 
b/itests/src/test/resources/testconfiguration.properties
index af0bc66..b020ca4 100644
--- a/itests/src/test/resources/testconfiguration.properties
+++ b/itests/src/test/resources/testconfiguration.properties
@@ -529,6 +529,7 @@ minillaplocal.query.files=\
   external_jdbc_auth.q,\
   external_jdbc_table.q,\
   external_jdbc_table2.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/86009a0d/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/86009a0d/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/86009a0d/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

Reply via email to