FAQ
Repository: hive
Updated Branches:
   refs/heads/master 9a16be1f2 -> 185531a10


HIVE-10421: DROP TABLE with qualified table name ignores database name when checking partitions (Jason Dere via Thejas Nair)


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

Branch: refs/heads/master
Commit: 185531a10998c9b931c17e5f60bc69bcfcb16734
Parents: 9a16be1
Author: Jason Dere <jdere@hortonworks.com>
Authored: Mon Apr 27 11:37:43 2015 -0700
Committer: Jason Dere <jdere@hortonworks.com>
Committed: Mon Apr 27 11:37:43 2015 -0700

----------------------------------------------------------------------
  .../org/apache/hadoop/hive/ql/exec/DDLTask.java | 2 +-
  .../clientnegative/protectmode_part_no_drop2.q | 11 +++++
  .../protectmode_part_no_drop2.q.out | 51 ++++++++++++++++++++
  3 files changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/185531a1/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
index f1040b2..04c89ae 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
@@ -3816,7 +3816,7 @@ public class DDLTask extends Task<DDLWork> implements Serializable {

      // We should check that all the partitions of the table can be dropped
      if (tbl != null && tbl.isPartitioned()) {
- List<String> partitionNames = db.getPartitionNames(tbl.getTableName(), (short)-1);
+ List<String> partitionNames = db.getPartitionNames(tbl.getDbName(), tbl.getTableName(), (short)-1);

        for(int i=0; i < partitionNames.size(); i+= partitionBatchSize) {
          List<String> partNames = partitionNames.subList(i, Math.min(i+partitionBatchSize,

http://git-wip-us.apache.org/repos/asf/hive/blob/185531a1/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q b/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q
new file mode 100644
index 0000000..e7e8c42
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q
@@ -0,0 +1,11 @@
+-- protect mode: syntax to change protect mode works and queries to drop partitions are blocked if it is marked no drop
+
+create database if not exists db1;
+use db1;
+
+create table tbl_protectmode_no_drop2 (c1 string,c2 string) partitioned by (p string);
+alter table tbl_protectmode_no_drop2 add partition (p='p1');
+alter table tbl_protectmode_no_drop2 partition (p='p1') enable no_drop;
+
+use default;
+drop table db1.tbl_protectmode_no_drop2;

http://git-wip-us.apache.org/repos/asf/hive/blob/185531a1/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out b/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out
new file mode 100644
index 0000000..527198c
--- /dev/null
+++ b/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out
@@ -0,0 +1,51 @@
+PREHOOK: query: -- protect mode: syntax to change protect mode works and queries to drop partitions are blocked if it is marked no drop
+
+create database if not exists db1
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:db1
+POSTHOOK: query: -- protect mode: syntax to change protect mode works and queries to drop partitions are blocked if it is marked no drop
+
+create database if not exists db1
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:db1
+PREHOOK: query: use db1
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:db1
+POSTHOOK: query: use db1
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:db1
+PREHOOK: query: create table tbl_protectmode_no_drop2 (c1 string,c2 string) partitioned by (p string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:db1
+PREHOOK: Output: db1@tbl_protectmode_no_drop2
+POSTHOOK: query: create table tbl_protectmode_no_drop2 (c1 string,c2 string) partitioned by (p string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:db1
+POSTHOOK: Output: db1@tbl_protectmode_no_drop2
+PREHOOK: query: alter table tbl_protectmode_no_drop2 add partition (p='p1')
+PREHOOK: type: ALTERTABLE_ADDPARTS
+PREHOOK: Output: db1@tbl_protectmode_no_drop2
+POSTHOOK: query: alter table tbl_protectmode_no_drop2 add partition (p='p1')
+POSTHOOK: type: ALTERTABLE_ADDPARTS
+POSTHOOK: Output: db1@tbl_protectmode_no_drop2
+POSTHOOK: Output: db1@tbl_protectmode_no_drop2@p=p1
+PREHOOK: query: alter table tbl_protectmode_no_drop2 partition (p='p1') enable no_drop
+PREHOOK: type: ALTERPARTITION_PROTECTMODE
+PREHOOK: Input: db1@tbl_protectmode_no_drop2
+PREHOOK: Output: db1@tbl_protectmode_no_drop2@p=p1
+POSTHOOK: query: alter table tbl_protectmode_no_drop2 partition (p='p1') enable no_drop
+POSTHOOK: type: ALTERPARTITION_PROTECTMODE
+POSTHOOK: Input: db1@tbl_protectmode_no_drop2
+POSTHOOK: Input: db1@tbl_protectmode_no_drop2@p=p1
+POSTHOOK: Output: db1@tbl_protectmode_no_drop2@p=p1
+PREHOOK: query: use default
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:default
+POSTHOOK: query: use default
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:default
+PREHOOK: query: drop table db1.tbl_protectmode_no_drop2
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: db1@tbl_protectmode_no_drop2
+PREHOOK: Output: db1@tbl_protectmode_no_drop2
+FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Table tbl_protectmode_no_drop2 Partitionp=p1 is protected from being dropped

Search Discussions

  • Jdere at Apr 27, 2015 at 10:00 pm
    Repository: hive
    Updated Branches:
       refs/heads/branch-1.2 7ee0848bd -> 5bc1be5f3


    HIVE-10421: DROP TABLE with qualified table name ignores database name when checking partitions (Jason Dere via Thejas Nair)


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

    Branch: refs/heads/branch-1.2
    Commit: 5bc1be5f3f2500f8b5930f3c6b4393fc5d2ccb39
    Parents: 7ee0848
    Author: Jason Dere <jdere@hortonworks.com>
    Authored: Mon Apr 27 11:37:43 2015 -0700
    Committer: Jason Dere <jdere@hortonworks.com>
    Committed: Mon Apr 27 14:56:24 2015 -0700

    ----------------------------------------------------------------------
      .../org/apache/hadoop/hive/ql/exec/DDLTask.java | 2 +-
      .../clientnegative/protectmode_part_no_drop2.q | 11 +++++
      .../protectmode_part_no_drop2.q.out | 51 ++++++++++++++++++++
      3 files changed, 63 insertions(+), 1 deletion(-)
    ----------------------------------------------------------------------


    http://git-wip-us.apache.org/repos/asf/hive/blob/5bc1be5f/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    ----------------------------------------------------------------------
    diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    index f1040b2..04c89ae 100644
    --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    @@ -3816,7 +3816,7 @@ public class DDLTask extends Task<DDLWork> implements Serializable {

          // We should check that all the partitions of the table can be dropped
          if (tbl != null && tbl.isPartitioned()) {
    - List<String> partitionNames = db.getPartitionNames(tbl.getTableName(), (short)-1);
    + List<String> partitionNames = db.getPartitionNames(tbl.getDbName(), tbl.getTableName(), (short)-1);

            for(int i=0; i < partitionNames.size(); i+= partitionBatchSize) {
              List<String> partNames = partitionNames.subList(i, Math.min(i+partitionBatchSize,

    http://git-wip-us.apache.org/repos/asf/hive/blob/5bc1be5f/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q
    ----------------------------------------------------------------------
    diff --git a/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q b/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q
    new file mode 100644
    index 0000000..e7e8c42
    --- /dev/null
    +++ b/ql/src/test/queries/clientnegative/protectmode_part_no_drop2.q
    @@ -0,0 +1,11 @@
    +-- protect mode: syntax to change protect mode works and queries to drop partitions are blocked if it is marked no drop
    +
    +create database if not exists db1;
    +use db1;
    +
    +create table tbl_protectmode_no_drop2 (c1 string,c2 string) partitioned by (p string);
    +alter table tbl_protectmode_no_drop2 add partition (p='p1');
    +alter table tbl_protectmode_no_drop2 partition (p='p1') enable no_drop;
    +
    +use default;
    +drop table db1.tbl_protectmode_no_drop2;

    http://git-wip-us.apache.org/repos/asf/hive/blob/5bc1be5f/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out
    ----------------------------------------------------------------------
    diff --git a/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out b/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out
    new file mode 100644
    index 0000000..527198c
    --- /dev/null
    +++ b/ql/src/test/results/clientnegative/protectmode_part_no_drop2.q.out
    @@ -0,0 +1,51 @@
    +PREHOOK: query: -- protect mode: syntax to change protect mode works and queries to drop partitions are blocked if it is marked no drop
    +
    +create database if not exists db1
    +PREHOOK: type: CREATEDATABASE
    +PREHOOK: Output: database:db1
    +POSTHOOK: query: -- protect mode: syntax to change protect mode works and queries to drop partitions are blocked if it is marked no drop
    +
    +create database if not exists db1
    +POSTHOOK: type: CREATEDATABASE
    +POSTHOOK: Output: database:db1
    +PREHOOK: query: use db1
    +PREHOOK: type: SWITCHDATABASE
    +PREHOOK: Input: database:db1
    +POSTHOOK: query: use db1
    +POSTHOOK: type: SWITCHDATABASE
    +POSTHOOK: Input: database:db1
    +PREHOOK: query: create table tbl_protectmode_no_drop2 (c1 string,c2 string) partitioned by (p string)
    +PREHOOK: type: CREATETABLE
    +PREHOOK: Output: database:db1
    +PREHOOK: Output: db1@tbl_protectmode_no_drop2
    +POSTHOOK: query: create table tbl_protectmode_no_drop2 (c1 string,c2 string) partitioned by (p string)
    +POSTHOOK: type: CREATETABLE
    +POSTHOOK: Output: database:db1
    +POSTHOOK: Output: db1@tbl_protectmode_no_drop2
    +PREHOOK: query: alter table tbl_protectmode_no_drop2 add partition (p='p1')
    +PREHOOK: type: ALTERTABLE_ADDPARTS
    +PREHOOK: Output: db1@tbl_protectmode_no_drop2
    +POSTHOOK: query: alter table tbl_protectmode_no_drop2 add partition (p='p1')
    +POSTHOOK: type: ALTERTABLE_ADDPARTS
    +POSTHOOK: Output: db1@tbl_protectmode_no_drop2
    +POSTHOOK: Output: db1@tbl_protectmode_no_drop2@p=p1
    +PREHOOK: query: alter table tbl_protectmode_no_drop2 partition (p='p1') enable no_drop
    +PREHOOK: type: ALTERPARTITION_PROTECTMODE
    +PREHOOK: Input: db1@tbl_protectmode_no_drop2
    +PREHOOK: Output: db1@tbl_protectmode_no_drop2@p=p1
    +POSTHOOK: query: alter table tbl_protectmode_no_drop2 partition (p='p1') enable no_drop
    +POSTHOOK: type: ALTERPARTITION_PROTECTMODE
    +POSTHOOK: Input: db1@tbl_protectmode_no_drop2
    +POSTHOOK: Input: db1@tbl_protectmode_no_drop2@p=p1
    +POSTHOOK: Output: db1@tbl_protectmode_no_drop2@p=p1
    +PREHOOK: query: use default
    +PREHOOK: type: SWITCHDATABASE
    +PREHOOK: Input: database:default
    +POSTHOOK: query: use default
    +POSTHOOK: type: SWITCHDATABASE
    +POSTHOOK: Input: database:default
    +PREHOOK: query: drop table db1.tbl_protectmode_no_drop2
    +PREHOOK: type: DROPTABLE
    +PREHOOK: Input: db1@tbl_protectmode_no_drop2
    +PREHOOK: Output: db1@tbl_protectmode_no_drop2
    +FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Table tbl_protectmode_no_drop2 Partitionp=p1 is protected from being dropped

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedApr 27, '15 at 6:38p
activeApr 27, '15 at 10:00p
posts2
users1
websitehive.apache.org

1 user in discussion

Jdere: 2 posts

People

Translate

site design / logo © 2021 Grokbase