You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2019/09/30 19:32:20 UTC
[hive] branch master updated: HIVE-22209: Graceful error msg when
there is no table for a materialized view (Steve Carlin,
reviewed by Jesus Camacho Rodriguez)
This is an automated email from the ASF dual-hosted git repository.
jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 8b15c75 HIVE-22209: Graceful error msg when there is no table for a materialized view (Steve Carlin, reviewed by Jesus Camacho Rodriguez)
8b15c75 is described below
commit 8b15c75a85dc135e653c8231dbf4bc09312a4433
Author: Steve Carlin <sc...@cloudera.com>
AuthorDate: Wed Sep 18 10:13:59 2019 -0700
HIVE-22209: Graceful error msg when there is no table for a materialized view (Steve Carlin, reviewed by Jesus Camacho Rodriguez)
Close apache/hive#782
---
ql/src/java/org/apache/hadoop/hive/ql/parse/QB.java | 7 +++++++
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java | 4 ++++
ql/src/test/queries/clientnegative/materialized_view_no_tbl.q | 4 ++++
ql/src/test/results/clientnegative/materialized_view_no_tbl.q.out | 1 +
4 files changed, 16 insertions(+)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/QB.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/QB.java
index 18de383..dc84c98 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/QB.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/QB.java
@@ -456,4 +456,11 @@ public class QB {
}
return aliasToTabs.size()==0 && aliasToSubq.size()==0;
}
+
+ // returns false when the query block doesn't have
+ // a table defined, e.g. "select 5"
+ public boolean hasTableDefined() {
+ return !(aliases.size() == 1 && aliases.get(0).equals(SemanticAnalyzer.DUMMY_TABLE));
+ }
+
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 4a54dae..8cd4ba0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -13895,6 +13895,10 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
}
}
+ if (createVwDesc.isMaterialized() && !qb.hasTableDefined()) {
+ throw new SemanticException("Materialized view must have a table defined.");
+ }
+
if (createVwDesc.isMaterialized() && createVwDesc.isRewriteEnabled()) {
if (!ctx.isCboSucceeded()) {
String msg = "Cannot enable automatic rewriting for materialized view.";
diff --git a/ql/src/test/queries/clientnegative/materialized_view_no_tbl.q b/ql/src/test/queries/clientnegative/materialized_view_no_tbl.q
new file mode 100644
index 0000000..91ceea9
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/materialized_view_no_tbl.q
@@ -0,0 +1,4 @@
+set hive.support.concurrency=true;
+set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+create materialized view cmv_no_tbl_as AS select 5;
diff --git a/ql/src/test/results/clientnegative/materialized_view_no_tbl.q.out b/ql/src/test/results/clientnegative/materialized_view_no_tbl.q.out
new file mode 100644
index 0000000..8de568e
--- /dev/null
+++ b/ql/src/test/results/clientnegative/materialized_view_no_tbl.q.out
@@ -0,0 +1 @@
+FAILED: SemanticException Materialized view must have a table defined.