diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java index fe507b48c2..7e20fb0cb5 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java @@ -1197,7 +1197,7 @@ PartitionSpecProxy listPartitionSpecs(String catName, String dbName, String tabl * @param tbl_name table name. * @param part_vals partial list of partition values. These must be given in the order of the * partition keys. If you wish to accept any value for a particular key you - * can pass ".*" for that value in this list. + * can pass empty string "" for that value in this list. * @param max_parts maximum number of partition names to return, or -1 to return all that are * found. * @return list of matching partition names. diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java index a8b6e316da..6e62377471 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java @@ -1038,6 +1038,31 @@ public void testListPartitionNames() throws Exception { } + @Test + public void testListPartitionNamesByEmptyStringPartVal() throws Exception { + Table t = createTestTable(client, DB_NAME, TABLE_NAME, Lists.newArrayList("yyyy", "mm", "dd"), false); + List> testValuesWithRepeatedDayNumber = Lists.newArrayList( + Lists.newArrayList("1999", "01", "02"), + Lists.newArrayList("1999", "02", "02"), + Lists.newArrayList("1999", "03", "02"), + Lists.newArrayList("2009", "02", "10"), + Lists.newArrayList("2017", "10", "26"), + Lists.newArrayList("2017", "11", "27")); + + for(List vals : testValuesWithRepeatedDayNumber) { + addPartition(client, t, vals); + } + + List partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, + Lists.newArrayList("", "", "02"), (short) -1); + assertEquals(3, partitionNames.size()); + assertCorrectPartitionNames(partitionNames, testValuesWithRepeatedDayNumber.subList(0, 3), + Lists.newArrayList("yyyy", "mm", "dd")); + partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, + Lists.newArrayList(".*", ".*", "02"), (short) -1); + assertEquals(0, partitionNames.size()); + } + @Test(expected = NoSuchObjectException.class) public void testListPartitionNamesNoDbName() throws Exception { createTable4PartColsParts(client);