HIVE-17419: ANALYZE TABLE...COMPUTE STATISTICS FOR COLUMNS command shows 
computed stats for masked tables (Jesus Camacho Rodriguez, 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/65480cec
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/65480cec
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/65480cec

Branch: refs/heads/hive-14535
Commit: 65480cecfd329d096bb701196eb57838fcfda218
Parents: 5f26f39
Author: Jesus Camacho Rodriguez <jcama...@apache.org>
Authored: Fri Sep 8 09:14:34 2017 -0700
Committer: Jesus Camacho Rodriguez <jcama...@apache.org>
Committed: Fri Sep 8 09:14:34 2017 -0700

----------------------------------------------------------------------
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |  5 +++--
 ql/src/test/queries/clientpositive/masking_11.q |  6 ++++++
 .../results/clientpositive/masking_11.q.out     | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/65480cec/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
----------------------------------------------------------------------
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 6f379da..cebb0af 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
@@ -3513,7 +3513,7 @@ public class SemanticAnalyzer extends 
BaseSemanticAnalyzer {
           pos = Integer.valueOf(pos.intValue() + 1);
           matched++;
 
-          if (unparseTranslator.isEnabled() || tableMask.isEnabled()) {
+          if (unparseTranslator.isEnabled() || (tableMask.isEnabled() && 
analyzeRewrite == null)) {
             if (replacementText.length() > 0) {
               replacementText.append(", ");
             }
@@ -11331,7 +11331,8 @@ public class SemanticAnalyzer extends 
BaseSemanticAnalyzer {
     // 2. Gen OP Tree from resolved Parse Tree
     Operator sinkOp = genOPTree(ast, plannerCtx);
 
-    if (!unparseTranslator.isEnabled() && tableMask.isEnabled()) {
+    if (!unparseTranslator.isEnabled() &&
+            (tableMask.isEnabled() && analyzeRewrite == null)) {
       // Here we rewrite the * and also the masking table
       ASTNode tree = rewriteASTWithMaskAndFilter(ast);
       if (tree != ast) {

http://git-wip-us.apache.org/repos/asf/hive/blob/65480cec/ql/src/test/queries/clientpositive/masking_11.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/masking_11.q 
b/ql/src/test/queries/clientpositive/masking_11.q
new file mode 100644
index 0000000..dc46117
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/masking_11.q
@@ -0,0 +1,6 @@
+set hive.mapred.mode=nonstrict;
+set 
hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactoryForTest;
+
+create table `masking_test` as select cast(key as int) as key, value from src;
+
+analyze table `masking_test` compute statistics for columns;

http://git-wip-us.apache.org/repos/asf/hive/blob/65480cec/ql/src/test/results/clientpositive/masking_11.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/masking_11.q.out 
b/ql/src/test/results/clientpositive/masking_11.q.out
new file mode 100644
index 0000000..f29c51f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/masking_11.q.out
@@ -0,0 +1,20 @@
+PREHOOK: query: create table `masking_test` as select cast(key as int) as key, 
value from src
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+PREHOOK: Output: database:default
+PREHOOK: Output: default@masking_test
+POSTHOOK: query: create table `masking_test` as select cast(key as int) as 
key, value from src
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@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: analyze table `masking_test` compute statistics for columns
+PREHOOK: type: QUERY
+PREHOOK: Input: default@masking_test
+#### A masked pattern was here ####
+POSTHOOK: query: analyze table `masking_test` compute statistics for columns
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@masking_test
+#### A masked pattern was here ####

Reply via email to