hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pxi...@apache.org
Subject hive git commit: HIVE-13910: [Ranger-Hive] select from a table is not working if used as <dbname.tablename> (Pengcheng Xiong, reviewed by Ashutosh Chauhan)
Date Fri, 03 Jun 2016 21:05:56 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.1 712721157 -> 64e3feac5


HIVE-13910: [Ranger-Hive] select from a table is not working if used as <dbname.tablename>
(Pengcheng Xiong, reviewed by Ashutosh Chauhan)


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

Branch: refs/heads/branch-2.1
Commit: 64e3feac598f1cb5afa5c5a3e54617da1d304694
Parents: 7127211
Author: Pengcheng Xiong <pxiong@apache.org>
Authored: Fri Jun 3 11:33:43 2016 -0700
Committer: Pengcheng Xiong <pxiong@apache.org>
Committed: Fri Jun 3 14:05:46 2016 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/parse/TableMask.java  |   4 +-
 .../queries/clientpositive/masking_1_newdb.q    |  17 +++
 .../clientpositive/masking_1_newdb.q.out        | 127 +++++++++++++++++++
 3 files changed, 146 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/64e3feac/ql/src/java/org/apache/hadoop/hive/ql/parse/TableMask.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/TableMask.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/TableMask.java
index 41d5900..1686f36 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/TableMask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/TableMask.java
@@ -107,7 +107,7 @@ public class TableMask {
         String colName = privObject.getColumns().get(index);
         if (!expr.equals(colName)) {
           // CAST(expr AS COLTYPE) AS COLNAME
-          sb.append("CAST(" + expr + " AS " + colTypes.get(index) + ") AS " + colName);
+          sb.append("CAST(" + expr + " AS " + colTypes.get(index) + ") AS `" + colName +
"`");
         } else {
           sb.append(expr);
         }
@@ -123,7 +123,7 @@ public class TableMask {
         sb.append(expr);
       }
     }
-    sb.append(" FROM " + privObject.getObjectName());
+    sb.append(" FROM `" + privObject.getDbname() + "`.`" + privObject.getObjectName() + "`");
     sb.append(" " + maskAndFilterInfo.additionalTabInfo);
     String filter = privObject.getRowFilterExpression();
     if (filter != null) {

http://git-wip-us.apache.org/repos/asf/hive/blob/64e3feac/ql/src/test/queries/clientpositive/masking_1_newdb.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/masking_1_newdb.q b/ql/src/test/queries/clientpositive/masking_1_newdb.q
new file mode 100644
index 0000000..42c33dc
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/masking_1_newdb.q
@@ -0,0 +1,17 @@
+set hive.mapred.mode=nonstrict;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactoryForTest;
+
+create database newdb;
+
+use newdb;
+
+create table masking_test as select cast(key as int) as key, value from default.src;
+
+use default;
+
+explain select * from newdb.masking_test;
+select * from newdb.masking_test;
+
+explain select * from newdb.masking_test where key > 0;
+select * from newdb.masking_test where key > 0;
+

http://git-wip-us.apache.org/repos/asf/hive/blob/64e3feac/ql/src/test/results/clientpositive/masking_1_newdb.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/masking_1_newdb.q.out b/ql/src/test/results/clientpositive/masking_1_newdb.q.out
new file mode 100644
index 0000000..51c2619
--- /dev/null
+++ b/ql/src/test/results/clientpositive/masking_1_newdb.q.out
@@ -0,0 +1,127 @@
+PREHOOK: query: create database newdb
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:newdb
+POSTHOOK: query: create database newdb
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:newdb
+PREHOOK: query: use newdb
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:newdb
+POSTHOOK: query: use newdb
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:newdb
+PREHOOK: query: create table masking_test as select cast(key as int) as key, value from default.src
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+PREHOOK: Output: database:newdb
+PREHOOK: Output: newdb@masking_test
+POSTHOOK: query: create table masking_test as select cast(key as int) as key, value from
default.src
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:newdb
+POSTHOOK: Output: newdb@masking_test
+POSTHOOK: Lineage: masking_test.key EXPRESSION [(src)src.FieldSchema(name:key, type:string,
comment:default), ]
+POSTHOOK: Lineage: masking_test.value SIMPLE [(src)src.FieldSchema(name:value, type:string,
comment:default), ]
+PREHOOK: query: use default
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:default
+POSTHOOK: query: use default
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:default
+PREHOOK: query: explain select * from newdb.masking_test
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select * from newdb.masking_test
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: masking_test
+            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
+            Filter Operator
+              predicate: (((key % 2) = 0) and (key < 10)) (type: boolean)
+              Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE Column stats:
NONE
+              Select Operator
+                expressions: key (type: int), reverse(value) (type: string)
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE Column stats:
NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE Column stats:
NONE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select * from newdb.masking_test
+PREHOOK: type: QUERY
+PREHOOK: Input: newdb@masking_test
+#### A masked pattern was here ####
+POSTHOOK: query: select * from newdb.masking_test
+POSTHOOK: type: QUERY
+POSTHOOK: Input: newdb@masking_test
+#### A masked pattern was here ####
+0	0_lav
+4	4_lav
+8	8_lav
+0	0_lav
+0	0_lav
+2	2_lav
+PREHOOK: query: explain select * from newdb.masking_test where key > 0
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select * from newdb.masking_test where key > 0
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: masking_test
+            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats:
NONE
+            Filter Operator
+              predicate: (((key % 2) = 0) and (key < 10) and (key > 0)) (type: boolean)
+              Statistics: Num rows: 27 Data size: 286 Basic stats: COMPLETE Column stats:
NONE
+              Select Operator
+                expressions: key (type: int), reverse(value) (type: string)
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 27 Data size: 286 Basic stats: COMPLETE Column stats:
NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 27 Data size: 286 Basic stats: COMPLETE Column stats:
NONE
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select * from newdb.masking_test where key > 0
+PREHOOK: type: QUERY
+PREHOOK: Input: newdb@masking_test
+#### A masked pattern was here ####
+POSTHOOK: query: select * from newdb.masking_test where key > 0
+POSTHOOK: type: QUERY
+POSTHOOK: Input: newdb@masking_test
+#### A masked pattern was here ####
+4	4_lav
+8	8_lav
+2	2_lav


Mime
View raw message