FAQ
Author: namit
Date: Thu Nov 22 06:08:29 2012
New Revision: 1412432

URL: http://svn.apache.org/viewvc?rev=1412432&view=rev
Log:
HIVE-3721 ALTER TABLE ADD PARTS should check for valid partition spec and throw a SemanticException
if part spec is not valid (Pamela Vagata via namit)


Added:
hive/trunk/ql/src/test/queries/clientnegative/alter_table_add_partition.q
hive/trunk/ql/src/test/results/clientnegative/alter_table_add_partition.q.out
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java?rev=1412432&r1=1412431&r2=1412432&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java Thu Nov 22 06:08:29 2012
@@ -291,6 +291,7 @@ public enum ErrorMsg {

HIVE_GROUPING_SETS_EXPR_NOT_IN_GROUPBY(10213,
"Grouping sets expression is not in GROUP BY key"),
+ INVALID_PARTITION_SPEC(10214, "Invalid partition spec specified"),

SCRIPT_INIT_ERROR(20000, "Unable to initialize custom script."),
SCRIPT_IO_ERROR(20001, "An error occurred while reading or writing to your custom script. "

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java?rev=1412432&r1=1412431&r2=1412432&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java Thu Nov 22 06:08:29 2012
@@ -2325,6 +2325,11 @@ public class DDLSemanticAnalyzer extends
}

for (AddPartitionDesc addPartitionDesc : partitionDescs) {
+ try {
+ tab.isValidSpec(addPartitionDesc.getPartSpec());
+ } catch (HiveException ex) {
+ throw new SemanticException(ErrorMsg.INVALID_PARTITION_SPEC.getMsg(ex.getMessage()));
+ }
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
addPartitionDesc), conf));
}
@@ -2344,7 +2349,7 @@ public class DDLSemanticAnalyzer extends
// actually returns false).
tab.isValidSpec(partitionDesc.getPartSpec());
} catch (HiveException ex) {
- throw new SemanticException(ex.getMessage(), ex);
+ throw new SemanticException(ErrorMsg.INVALID_PARTITION_SPEC.getMsg(ex.getMessage()));
}
if (firstOr) {
firstOr = false;

Added: hive/trunk/ql/src/test/queries/clientnegative/alter_table_add_partition.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/alter_table_add_partition.q?rev=1412432&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/alter_table_add_partition.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/alter_table_add_partition.q Thu Nov 22 06:08:29 2012
@@ -0,0 +1,5 @@
+create table mp (a int) partitioned by (b int);
+
+-- should fail
+alter table mp add partition (b='1', c='1');
+

Added: hive/trunk/ql/src/test/results/clientnegative/alter_table_add_partition.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/alter_table_add_partition.q.out?rev=1412432&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/alter_table_add_partition.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/alter_table_add_partition.q.out Thu Nov 22 06:08:29 2012
@@ -0,0 +1,6 @@
+PREHOOK: query: create table mp (a int) partitioned by (b int)
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: create table mp (a int) partitioned by (b int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@mp
+FAILED: SemanticException [Error 10214]: Invalid partition spec specified table is partitioned but partition spec is not specified or does not fully match table partitioning: {b=1, c=1}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedNov 22, '12 at 6:08a
activeNov 22, '12 at 6:08a
posts1
users1
websitehive.apache.org

1 user in discussion

Namit: 1 post

People

Translate

site design / logo © 2021 Grokbase