FAQ
Repository: hive
Updated Branches:
   refs/heads/master 8555d2aec -> df827b7d3


HIVE-12182: ALTER TABLE PARTITION COLUMN does not set partition column comments (Naveen Gangam via Yongzhi Chen)


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

Branch: refs/heads/master
Commit: df827b7d3feb7f109cab1ddd12b0cf134eb91283
Parents: 8555d2a
Author: Yongzhi Chen <ychena@apache.org>
Authored: Tue Dec 1 10:19:05 2015 -0500
Committer: Yongzhi Chen <ychena@apache.org>
Committed: Tue Dec 1 10:19:05 2015 -0500

----------------------------------------------------------------------
  .../hive/ql/parse/DDLSemanticAnalyzer.java | 5 +-
  .../clientpositive/alter_partition_change_col.q | 6 +-
  .../alter_partition_change_col.q.out | 125 +++++++++++--------
  3 files changed, 84 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/df827b7d/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
index 757542d..c407aae 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
@@ -2625,7 +2625,6 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer {
      // Alter table ... partition column ( column newtype) only takes one column at a time.
      // It must have a column name followed with type.
      ASTNode colAst = (ASTNode) ast.getChild(0);
- assert(colAst.getChildCount() == 2);

      FieldSchema newCol = new FieldSchema();

@@ -2637,6 +2636,10 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer {
      ASTNode typeChild = (ASTNode) (colAst.getChild(1));
      newCol.setType(getTypeStringFromAST(typeChild));

+ if (colAst.getChildCount() == 3) {
+ newCol.setComment(unescapeSQLString(colAst.getChild(2).getText()));
+ }
+
      // check if column is defined or not
      boolean fFoundColumn = false;
      for( FieldSchema col : tab.getTTable().getPartitionKeys()) {

http://git-wip-us.apache.org/repos/asf/hive/blob/df827b7d/ql/src/test/queries/clientpositive/alter_partition_change_col.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/alter_partition_change_col.q b/ql/src/test/queries/clientpositive/alter_partition_change_col.q
index 4451ef3..6861ca2 100644
--- a/ql/src/test/queries/clientpositive/alter_partition_change_col.q
+++ b/ql/src/test/queries/clientpositive/alter_partition_change_col.q
@@ -6,7 +6,7 @@ SET hive.exec.dynamic.partition.mode = nonstrict;
  create table alter_partition_change_col0 (c1 string, c2 string);
  load data local inpath '../../data/files/dec.txt' overwrite into table alter_partition_change_col0;

-create table alter_partition_change_col1 (c1 string, c2 string) partitioned by (p1 string, p2 string);
+create table alter_partition_change_col1 (c1 string, c2 string) partitioned by (p1 string comment 'Column p1', p2 string comment 'Column p2');

  insert overwrite table alter_partition_change_col1 partition (p1, p2)
    select c1, c2, 'abc', '123' from alter_partition_change_col0
@@ -31,6 +31,10 @@ describe alter_partition_change_col1 partition (p1='abc', p2='123');
  select * from alter_partition_change_col1 where p1='abc';
  select * from alter_partition_change_col1 where p1='__HIVE_DEFAULT_PARTITION__';

+-- change the comment on a partition column without changing type or renaming it
+alter table alter_partition_change_col1 partition column (p1 string comment 'Changed comment for p1');
+describe alter_partition_change_col1;
+
  -- now change the column type of the existing partition
  alter table alter_partition_change_col1 partition (p1='abc', p2='123') change c2 c2 decimal(14,4);
  describe alter_partition_change_col1 partition (p1='abc', p2='123');

http://git-wip-us.apache.org/repos/asf/hive/blob/df827b7d/ql/src/test/results/clientpositive/alter_partition_change_col.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/alter_partition_change_col.q.out b/ql/src/test/results/clientpositive/alter_partition_change_col.q.out
index 9e397c1..23febee 100644
--- a/ql/src/test/results/clientpositive/alter_partition_change_col.q.out
+++ b/ql/src/test/results/clientpositive/alter_partition_change_col.q.out
@@ -18,11 +18,11 @@ POSTHOOK: query: load data local inpath '../../data/files/dec.txt' overwrite int
  POSTHOOK: type: LOAD
  #### A masked pattern was here ####
  POSTHOOK: Output: default@alter_partition_change_col0
-PREHOOK: query: create table alter_partition_change_col1 (c1 string, c2 string) partitioned by (p1 string, p2 string)
+PREHOOK: query: create table alter_partition_change_col1 (c1 string, c2 string) partitioned by (p1 string comment 'Column p1', p2 string comment 'Column p2')
  PREHOOK: type: CREATETABLE
  PREHOOK: Output: database:default
  PREHOOK: Output: default@alter_partition_change_col1
-POSTHOOK: query: create table alter_partition_change_col1 (c1 string, c2 string) partitioned by (p1 string, p2 string)
+POSTHOOK: query: create table alter_partition_change_col1 (c1 string, c2 string) partitioned by (p1 string comment 'Column p1', p2 string comment 'Column p2')
  POSTHOOK: type: CREATETABLE
  POSTHOOK: Output: database:default
  POSTHOOK: Output: default@alter_partition_change_col1
@@ -179,14 +179,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(14,4)
-p1 string
-p2 string
+p1 string Column p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Column p1
+p2 string Column p2
  PREHOOK: query: describe alter_partition_change_col1 partition (p1='abc', p2='123')
  PREHOOK: type: DESCTABLE
  PREHOOK: Input: default@alter_partition_change_col1
@@ -195,14 +195,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(10,0)
-p1 string
-p2 string
+p1 string Column p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Column p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -243,6 +243,31 @@ Snow 56.0000 __HIVE_DEFAULT_PARTITION__ 123
  Tom -12.0000 __HIVE_DEFAULT_PARTITION__ 123
  Tom 19.0000 __HIVE_DEFAULT_PARTITION__ 123
  Tom 235.0000 __HIVE_DEFAULT_PARTITION__ 123
+PREHOOK: query: -- change the comment on a partition column without changing type or renaming it
+alter table alter_partition_change_col1 partition column (p1 string comment 'Changed comment for p1')
+PREHOOK: type: ALTERTABLE_PARTCOLTYPE
+PREHOOK: Input: default@alter_partition_change_col1
+POSTHOOK: query: -- change the comment on a partition column without changing type or renaming it
+alter table alter_partition_change_col1 partition column (p1 string comment 'Changed comment for p1')
+POSTHOOK: type: ALTERTABLE_PARTCOLTYPE
+POSTHOOK: Input: default@alter_partition_change_col1
+POSTHOOK: Output: default@alter_partition_change_col1
+PREHOOK: query: describe alter_partition_change_col1
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@alter_partition_change_col1
+POSTHOOK: query: describe alter_partition_change_col1
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@alter_partition_change_col1
+c1 string
+c2 decimal(14,4)
+p1 string Changed comment for p1
+p2 string Column p2
+
+# Partition Information
+# col_name data_type comment
+
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: -- now change the column type of the existing partition
  alter table alter_partition_change_col1 partition (p1='abc', p2='123') change c2 c2 decimal(14,4)
  PREHOOK: type: ALTERTABLE_RENAMECOL
@@ -262,14 +287,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(14,4)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -329,14 +354,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(14,4)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -396,14 +421,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(14,4)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: describe alter_partition_change_col1 partition (p1='abc', p2='123')
  PREHOOK: type: DESCTABLE
  PREHOOK: Input: default@alter_partition_change_col1
@@ -411,14 +436,14 @@ POSTHOOK: query: describe alter_partition_change_col1 partition (p1='abc', p2='1
  POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -474,14 +499,14 @@ POSTHOOK: query: describe alter_partition_change_col1
  POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -540,14 +565,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(14,4)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: describe alter_partition_change_col1 partition (p1='abc', p2='123')
  PREHOOK: type: DESCTABLE
  PREHOOK: Input: default@alter_partition_change_col1
@@ -555,14 +580,14 @@ POSTHOOK: query: describe alter_partition_change_col1 partition (p1='abc', p2='1
  POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -620,14 +645,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(14,4)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1
@@ -690,14 +715,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(10,0)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: describe alter_partition_change_col1 partition (p1='__HIVE_DEFAULT_PARTITION__', p2='123')
  PREHOOK: type: DESCTABLE
  PREHOOK: Input: default@alter_partition_change_col1
@@ -706,14 +731,14 @@ POSTHOOK: type: DESCTABLE
  POSTHOOK: Input: default@alter_partition_change_col1
  c1 string
  c2 decimal(10,0)
-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2

  # Partition Information
  # col_name data_type comment

-p1 string
-p2 string
+p1 string Changed comment for p1
+p2 string Column p2
  PREHOOK: query: select * from alter_partition_change_col1 where p1='abc'
  PREHOOK: type: QUERY
  PREHOOK: Input: default@alter_partition_change_col1

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedDec 1, '15 at 3:38p
activeDec 1, '15 at 3:42p
posts2
users1
websitehive.apache.org

1 user in discussion

Ychena: 2 posts

People

Translate

site design / logo © 2021 Grokbase