FAQ
Author: kevinwilfong
Date: Fri Jun 1 16:52:02 2012
New Revision: 1345274

URL: http://svn.apache.org/viewvc?rev=1345274&view=rev
Log:
HIVE-3076. drop partition does not work for non-partition columns (njain via kevinwilfong)

Added:
hive/trunk/ql/src/test/queries/clientpositive/drop_partitions_filter3.q
hive/trunk/ql/src/test/results/clientpositive/drop_partitions_filter3.q.out
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PartitionSpec.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java?rev=1345274&r1=1345273&r2=1345274&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java Fri Jun 1 16:52:02 2012
@@ -53,6 +53,7 @@ import org.apache.hadoop.hive.ql.metadat
import org.apache.hadoop.hive.ql.metadata.InvalidTableException;
import org.apache.hadoop.hive.ql.metadata.Partition;
import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.ql.plan.PlanUtils;
import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
import org.apache.hadoop.hive.serde.Constants;
import org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe;
@@ -271,12 +272,8 @@ public abstract class BaseSemanticAnalyz
rootTasks = new ArrayList<Task<? extends Serializable>>();
}

- public static String stripQuotes(String val) throws SemanticException {
- if ((val.charAt(0) == '\'' && val.charAt(val.length() - 1) == '\'')
- || (val.charAt(0) == '\"' && val.charAt(val.length() - 1) == '\"')) {
- val = val.substring(1, val.length() - 1);
- }
- return val;
+ public static String stripQuotes(String val) {
+ return PlanUtils.stripQuotes(val);
}

public static String charSetString(String charSetName, String charSetString)

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PartitionSpec.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PartitionSpec.java?rev=1345274&r1=1345273&r2=1345274&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PartitionSpec.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PartitionSpec.java Fri Jun 1 16:52:02 2012
@@ -18,7 +18,6 @@

package org.apache.hadoop.hive.ql.plan;

-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -110,9 +109,9 @@ public class PartitionSpec {
// For compatibility with other non-string partition columns, this function
// returns the key, value mapping assuming that the operator is equality.
public Map<String, String> getPartSpecWithoutOperator() {
- Map<String, String> partSpec = new HashMap<String, String>();
+ Map<String, String> partSpec = new LinkedHashMap<String, String>();
for (Map.Entry<String, PredicateSpec> entry: this.partSpec.entrySet()) {
- partSpec.put(entry.getKey(), entry.getValue().getValue());
+ partSpec.put(entry.getKey(), PlanUtils.stripQuotes(entry.getValue().getValue()));
}

return partSpec;

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java?rev=1345274&r1=1345273&r2=1345274&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java Fri Jun 1 16:52:02 2012
@@ -724,6 +724,14 @@ public final class PlanUtils {
}
}

+ public static String stripQuotes(String val) {
+ if ((val.charAt(0) == '\'' && val.charAt(val.length() - 1) == '\'')
+ || (val.charAt(0) == '\"' && val.charAt(val.length() - 1) == '\"')) {
+ val = val.substring(1, val.length() - 1);
+ }
+ return val;
+ }
+
private PlanUtils() {
// prevent instantiation
}

Added: hive/trunk/ql/src/test/queries/clientpositive/drop_partitions_filter3.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/drop_partitions_filter3.q?rev=1345274&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/drop_partitions_filter3.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/drop_partitions_filter3.q Fri Jun 1 16:52:02 2012
@@ -0,0 +1,20 @@
+create table ptestfilter (a string, b int) partitioned by (c string, d int);
+describe ptestfilter;
+
+alter table ptestfilter add partition (c='1', d=1);
+alter table ptestfilter add partition (c='1', d=2);
+alter table ptestFilter add partition (c='2', d=1);
+alter table ptestfilter add partition (c='2', d=2);
+alter table ptestfilter add partition (c='3', d=1);
+alter table ptestfilter add partition (c='3', d=2);
+show partitions ptestfilter;
+
+alter table ptestfilter drop partition (c='1', d=1);
+show partitions ptestfilter;
+
+alter table ptestfilter drop partition (c='2');
+show partitions ptestfilter;
+
+drop table ptestfilter;
+
+

Added: hive/trunk/ql/src/test/results/clientpositive/drop_partitions_filter3.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/drop_partitions_filter3.q.out?rev=1345274&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/drop_partitions_filter3.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/drop_partitions_filter3.q.out Fri Jun 1 16:52:02 2012
@@ -0,0 +1,107 @@
+PREHOOK: query: create table ptestfilter (a string, b int) partitioned by (c string, d int)
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: create table ptestfilter (a string, b int) partitioned by (c string, d int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@ptestfilter
+PREHOOK: query: describe ptestfilter
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: describe ptestfilter
+POSTHOOK: type: DESCTABLE
+a string
+b int
+c string
+d int
+PREHOOK: query: alter table ptestfilter add partition (c='1', d=1)
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@ptestfilter
+POSTHOOK: query: alter table ptestfilter add partition (c='1', d=1)
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=1/d=1
+PREHOOK: query: alter table ptestfilter add partition (c='1', d=2)
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@ptestfilter
+POSTHOOK: query: alter table ptestfilter add partition (c='1', d=2)
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=1/d=2
+PREHOOK: query: alter table ptestFilter add partition (c='2', d=1)
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@ptestfilter
+POSTHOOK: query: alter table ptestFilter add partition (c='2', d=1)
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=2/d=1
+PREHOOK: query: alter table ptestfilter add partition (c='2', d=2)
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@ptestfilter
+POSTHOOK: query: alter table ptestfilter add partition (c='2', d=2)
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=2/d=2
+PREHOOK: query: alter table ptestfilter add partition (c='3', d=1)
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@ptestfilter
+POSTHOOK: query: alter table ptestfilter add partition (c='3', d=1)
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=3/d=1
+PREHOOK: query: alter table ptestfilter add partition (c='3', d=2)
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Input: default@ptestfilter
+POSTHOOK: query: alter table ptestfilter add partition (c='3', d=2)
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=3/d=2
+PREHOOK: query: show partitions ptestfilter
+PREHOOK: type: SHOWPARTITIONS
+POSTHOOK: query: show partitions ptestfilter
+POSTHOOK: type: SHOWPARTITIONS
+c=1/d=1
+c=1/d=2
+c=2/d=1
+c=2/d=2
+c=3/d=1
+c=3/d=2
+PREHOOK: query: alter table ptestfilter drop partition (c='1', d=1)
+PREHOOK: type: ALTERTABLE_DROPPARTS
+PREHOOK: Input: default@ptestfilter
+PREHOOK: Output: default@ptestfilter@c=1/d=1
+POSTHOOK: query: alter table ptestfilter drop partition (c='1', d=1)
+POSTHOOK: type: ALTERTABLE_DROPPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=1/d=1
+PREHOOK: query: show partitions ptestfilter
+PREHOOK: type: SHOWPARTITIONS
+POSTHOOK: query: show partitions ptestfilter
+POSTHOOK: type: SHOWPARTITIONS
+c=1/d=2
+c=2/d=1
+c=2/d=2
+c=3/d=1
+c=3/d=2
+PREHOOK: query: alter table ptestfilter drop partition (c='2')
+PREHOOK: type: ALTERTABLE_DROPPARTS
+PREHOOK: Input: default@ptestfilter
+PREHOOK: Output: default@ptestfilter@c=2/d=1
+PREHOOK: Output: default@ptestfilter@c=2/d=2
+POSTHOOK: query: alter table ptestfilter drop partition (c='2')
+POSTHOOK: type: ALTERTABLE_DROPPARTS
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter@c=2/d=1
+POSTHOOK: Output: default@ptestfilter@c=2/d=2
+PREHOOK: query: show partitions ptestfilter
+PREHOOK: type: SHOWPARTITIONS
+POSTHOOK: query: show partitions ptestfilter
+POSTHOOK: type: SHOWPARTITIONS
+c=1/d=2
+c=3/d=1
+c=3/d=2
+PREHOOK: query: drop table ptestfilter
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@ptestfilter
+PREHOOK: Output: default@ptestfilter
+POSTHOOK: query: drop table ptestfilter
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@ptestfilter
+POSTHOOK: Output: default@ptestfilter

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedJun 1, '12 at 4:52p
activeJun 1, '12 at 4:52p
posts1
users1
websitehive.apache.org

1 user in discussion

Kevinwilfong: 1 post

People

Translate

site design / logo © 2021 Grokbase