You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by px...@apache.org on 2017/03/20 06:47:51 UTC
hive git commit: HIVE-16232: Support stats computation for columns in
QuotedIdentifier (Pengcheng Xiong, reviewed by Ashutosh Chauhan)
Repository: hive
Updated Branches:
refs/heads/master 27f27219a -> 3e5987732
HIVE-16232: Support stats computation for columns in QuotedIdentifier (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/3e598773
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/3e598773
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/3e598773
Branch: refs/heads/master
Commit: 3e59877326dbd0ce9987eac9485c4d43d958e067
Parents: 27f2721
Author: Pengcheng Xiong <px...@apache.org>
Authored: Sun Mar 19 23:47:30 2017 -0700
Committer: Pengcheng Xiong <px...@apache.org>
Committed: Sun Mar 19 23:47:49 2017 -0700
----------------------------------------------------------------------
.../ql/parse/ColumnStatsSemanticAnalyzer.java | 6 +-
.../queries/clientpositive/quotedid_stats.q | 11 +++
.../results/clientpositive/quotedid_stats.q.out | 86 ++++++++++++++++++++
3 files changed, 102 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/3e598773/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java
index 93b8183..08d0544 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java
@@ -242,6 +242,10 @@ public class ColumnStatsSemanticAnalyzer extends SemanticAnalyzer {
return colTypes;
}
+ private String escapeBackTicks(String colName) {
+ return colName.replaceAll("`", "``");
+ }
+
private String genRewrittenQuery(List<String> colNames, int numBitVectors, Map<String,String> partSpec,
boolean isPartitionStats) throws SemanticException{
StringBuilder rewrittenQueryBuilder = new StringBuilder("select ");
@@ -252,7 +256,7 @@ public class ColumnStatsSemanticAnalyzer extends SemanticAnalyzer {
rewrittenQueryBuilder.append(" , ");
}
rewrittenQueryBuilder.append("compute_stats(`");
- rewrittenQueryBuilder.append(colNames.get(i));
+ rewrittenQueryBuilder.append(escapeBackTicks(colNames.get(i)));
rewrittenQueryBuilder.append("` , ");
rewrittenQueryBuilder.append(numBitVectors);
rewrittenQueryBuilder.append(" )");
http://git-wip-us.apache.org/repos/asf/hive/blob/3e598773/ql/src/test/queries/clientpositive/quotedid_stats.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/quotedid_stats.q b/ql/src/test/queries/clientpositive/quotedid_stats.q
new file mode 100644
index 0000000..3f7e05c5
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/quotedid_stats.q
@@ -0,0 +1,11 @@
+set hive.mapred.mode=nonstrict;
+
+set hive.support.quoted.identifiers=column;
+
+-- escaped back ticks
+create table t4(`x+1``` string, `y&y` string);
+describe formatted t4;
+
+analyze table t4 compute statistics for columns;
+
+describe formatted t4;
http://git-wip-us.apache.org/repos/asf/hive/blob/3e598773/ql/src/test/results/clientpositive/quotedid_stats.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/quotedid_stats.q.out b/ql/src/test/results/clientpositive/quotedid_stats.q.out
new file mode 100644
index 0000000..a8cbb74
--- /dev/null
+++ b/ql/src/test/results/clientpositive/quotedid_stats.q.out
@@ -0,0 +1,86 @@
+PREHOOK: query: create table t4(`x+1``` string, `y&y` string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t4
+POSTHOOK: query: create table t4(`x+1``` string, `y&y` string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t4
+PREHOOK: query: describe formatted t4
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@t4
+POSTHOOK: query: describe formatted t4
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@t4
+# col_name data_type comment
+
+x+1` string
+y&y string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: MANAGED_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"}
+ numFiles 0
+ numRows 0
+ rawDataSize 0
+ totalSize 0
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+InputFormat: org.apache.hadoop.mapred.TextInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: analyze table t4 compute statistics for columns
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t4
+#### A masked pattern was here ####
+POSTHOOK: query: analyze table t4 compute statistics for columns
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t4
+#### A masked pattern was here ####
+PREHOOK: query: describe formatted t4
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@t4
+POSTHOOK: query: describe formatted t4
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@t4
+# col_name data_type comment
+
+x+1` string
+y&y string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: MANAGED_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"x+1`\":\"true\",\"y&y\":\"true\"}}
+ numFiles 0
+ numRows 0
+ rawDataSize 0
+ totalSize 0
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+InputFormat: org.apache.hadoop.mapred.TextInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1