You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kg...@apache.org on 2020/06/05 08:24:31 UTC
[hive] branch master updated: HIVE-23607: Permission Issue: Create
view on another view succeeds but alter view fails (#1058)
This is an automated email from the ASF dual-hosted git repository.
kgyrtkirk 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 5d932b5 HIVE-23607: Permission Issue: Create view on another view succeeds but alter view fails (#1058)
5d932b5 is described below
commit 5d932b50f1deee723af8e7c5638be754ae9af045
Author: Naresh P R <pr...@gmail.com>
AuthorDate: Fri Jun 5 01:24:13 2020 -0700
HIVE-23607: Permission Issue: Create view on another view succeeds but alter view fails (#1058)
---
.../hadoop/hive/ql/parse/SemanticAnalyzer.java | 2 +-
.../org/apache/hadoop/hive/ql/plan/PlanUtils.java | 2 +-
.../apache/hadoop/hive/ql/plan/TestViewEntity.java | 26 ++++++++++++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
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 8238a2a..68a43d7 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
@@ -2238,7 +2238,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
// Temporary tables created during the execution are not the input sources
if (!PlanUtils.isValuesTempTable(alias)) {
PlanUtils.addInput(inputs,
- new ReadEntity(tab, parentViewInfo, parentViewInfo == null),mergeIsDirect);
+ new ReadEntity(tab, parentViewInfo, parentViewInfo == null), mergeIsDirect);
}
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
index 2fb452b..fd3918a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
@@ -1172,7 +1172,7 @@ public final class PlanUtils {
// Adds tables only for create view (PPD filter can be appended by outer query)
Table table = topOp.getConf().getTableMetadata();
- PlanUtils.addInput(inputs, new ReadEntity(table, parentViewInfo));
+ PlanUtils.addInput(inputs, new ReadEntity(table, parentViewInfo, parentViewInfo == null));
}
}
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java b/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
index cbf1c83..d3a3cd5 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/plan/TestViewEntity.java
@@ -271,4 +271,30 @@ public class TestViewEntity {
}
+ /**
+ * Verify create/alter view on another view's underlying table is always indirect
+ * direct and indirect inputs.
+ * @throws CommandProcessorException
+ */
+ @Test
+ public void alterView() throws CommandProcessorException {
+
+ driver.run("create table test_table (id int)");
+ driver.run("create view test_view as select * from test_table");
+
+
+ driver.compile("create view test_view_1 as select * from test_view", true);
+ assertEquals("default@test_view", CheckInputReadEntity.readEntities[0].getName());
+ assertTrue("default@test_view", CheckInputReadEntity.readEntities[0].isDirect());
+ assertEquals("default@test_table", CheckInputReadEntity.readEntities[1].getName());
+ assertFalse("default@test_table", CheckInputReadEntity.readEntities[1].isDirect());
+
+ driver.run("create view test_view_1 as select * from test_view");
+
+ driver.compile("alter view test_view_1 as select * from test_view", true);
+ assertEquals("default@test_view", CheckInputReadEntity.readEntities[0].getName());
+ assertTrue("default@test_view", CheckInputReadEntity.readEntities[0].isDirect());
+ assertEquals("default@test_table", CheckInputReadEntity.readEntities[1].getName());
+ assertFalse("default@test_table", CheckInputReadEntity.readEntities[1].isDirect());
+ }
}