lirui-apache commented on a change in pull request #13157:
URL: https://github.com/apache/flink/pull/13157#discussion_r471253972



##########
File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
##########
@@ -777,8 +777,15 @@ public void dropPartition(ObjectPath tablePath, 
CatalogPartitionSpec partitionSp
                        // partition spec can be partial
                        List<String> partialVals = 
HiveReflectionUtils.getPvals(hiveShim, hiveTable.getPartitionKeys(),
                                partitionSpec.getPartitionSpec());
-                       return 
client.listPartitionNames(tablePath.getDatabaseName(), 
tablePath.getObjectName(), partialVals,
-                               (short) 
-1).stream().map(HiveCatalog::createPartitionSpec).collect(Collectors.toList());
+                       if (partialVals.size() == 1 && 
StringUtils.isNullOrWhitespaceOnly(partialVals.get(0))) {

Review comment:
       We can simply try calling `getOrderedFullPartitionValues`, which will 
check if the spec is valid

##########
File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
##########
@@ -765,7 +765,7 @@ public void dropPartition(ObjectPath tablePath, 
CatalogPartitionSpec partitionSp
 
        @Override
        public List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath, 
CatalogPartitionSpec partitionSpec)
-                       throws TableNotExistException, 
TableNotPartitionedException, CatalogException {
+                       throws TableNotExistException, 
TableNotPartitionedException, PartitionNotExistException, CatalogException {

Review comment:
       In case of invalid partition spec, we should throw 
`PartitionSpecInvalidException`

##########
File path: 
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java
##########
@@ -467,14 +468,36 @@ public void testAddDropPartitions() throws Exception {
 
        @Test
        public void testShowPartitions() throws Exception {
-               tableEnv.executeSql("create table tbl (x int,y binary) 
partitioned by (dt date, country string)");
-               tableEnv.executeSql("alter table tbl add partition 
(dt='2020-04-30',country='china') partition (dt='2020-04-30',country='us')");
+               tableEnv.executeSql("create table tbl (x int,y binary) 
partitioned by (country string)");

Review comment:
       Why do we need a different table schema? I think you can just reuse the 
table in this test




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to