[
https://issues.apache.org/jira/browse/HIVE-27150?focusedWorklogId=856150&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-856150
]
ASF GitHub Bot logged work on HIVE-27150:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 11/Apr/23 15:05
Start Date: 11/Apr/23 15:05
Worklog Time Spent: 10m
Work Description: wecharyu commented on code in PR #4123:
URL: https://github.com/apache/hive/pull/4123#discussion_r1162961355
##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java:
##########
@@ -498,6 +497,68 @@ public void testPartitionOpsWhenTableDoesNotExist() throws
InvalidObjectExceptio
}
}
+ @Test
+ public void testDropPartitionByName() throws Exception {
+ Database db1 = new DatabaseBuilder()
+ .setName(DB1)
+ .setDescription("description")
+ .setLocation("locationurl")
+ .build(conf);
+ try (AutoCloseable c = deadline()) {
+ objectStore.createDatabase(db1);
+ }
+ StorageDescriptor sd = createFakeSd("location");
+ HashMap<String, String> tableParams = new HashMap<>();
+ tableParams.put("EXTERNAL", "false");
+ FieldSchema partitionKey1 = new FieldSchema("Country",
ColumnType.STRING_TYPE_NAME, "");
+ FieldSchema partitionKey2 = new FieldSchema("State",
ColumnType.STRING_TYPE_NAME, "");
+ Table tbl1 =
+ new Table(TABLE1, DB1, "owner", 1, 2, 3, sd,
Arrays.asList(partitionKey1, partitionKey2),
+ tableParams, null, null, "MANAGED_TABLE");
+ try (AutoCloseable c = deadline()) {
+ objectStore.createTable(tbl1);
+ }
+ HashMap<String, String> partitionParams = new HashMap<>();
+ partitionParams.put("PARTITION_LEVEL_PRIVILEGE", "true");
+ List<String> value1 = Arrays.asList("US", "CA");
+ Partition part1 = new Partition(value1, DB1, TABLE1, 111, 111, sd,
partitionParams);
+ part1.setCatName(DEFAULT_CATALOG_NAME);
+ try (AutoCloseable c = deadline()) {
+ objectStore.addPartition(part1);
+ }
+ List<String> value2 = Arrays.asList("US", "MA");
+ Partition part2 = new Partition(value2, DB1, TABLE1, 222, 222, sd,
partitionParams);
+ part2.setCatName(DEFAULT_CATALOG_NAME);
+ try (AutoCloseable c = deadline()) {
+ objectStore.addPartition(part2);
+ }
+
+ List<Partition> partitions;
+ try (AutoCloseable c = deadline()) {
+ objectStore.dropPartition(DEFAULT_CATALOG_NAME, DB1, TABLE1,
"country=US/state=CA");
+ partitions = objectStore.getPartitions(DEFAULT_CATALOG_NAME, DB1,
TABLE1, 10);
+ }
+ Assert.assertEquals(1, partitions.size());
+ Assert.assertEquals(222, partitions.get(0).getCreateTime());
+ try (AutoCloseable c = deadline()) {
+ objectStore.dropPartition(DEFAULT_CATALOG_NAME, DB1, TABLE1,
"country=US/state=MA");
+ partitions = objectStore.getPartitions(DEFAULT_CATALOG_NAME, DB1,
TABLE1, 10);
+ }
+ Assert.assertEquals(0, partitions.size());
+
+ try (AutoCloseable c = deadline()) {
+ // Illegal partName will do nothing, it doesn't matter
+ // because the real HMSHandler will guarantee the partName is legal and
exists.
+ objectStore.dropPartition(DEFAULT_CATALOG_NAME, DB1, TABLE1,
"country=US/state=NON_EXIST");
+ objectStore.dropPartition(DEFAULT_CATALOG_NAME, DB1, TABLE1,
"country=US/st=CA");
Review Comment:
It will not return false for non-existent partition, `HMSHandler` has
already checked the existence of the partition and it does not need a double
check in `ObjectStore`.
Issue Time Tracking
-------------------
Worklog Id: (was: 856150)
Time Spent: 5h (was: 4h 50m)
> Drop single partition can also support direct sql
> -------------------------------------------------
>
> Key: HIVE-27150
> URL: https://issues.apache.org/jira/browse/HIVE-27150
> Project: Hive
> Issue Type: Improvement
> Components: Hive
> Reporter: Wechar
> Assignee: Wechar
> Priority: Major
> Labels: pull-request-available
> Time Spent: 5h
> Remaining Estimate: 0h
>
> *Background:*
> [HIVE-6980|https://issues.apache.org/jira/browse/HIVE-6980] supports direct
> sql for drop_partitions, we can reuse this huge improvement in drop_partition.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)