Skip to content

Commit

Permalink
HIVE-18567: ObjectStore.getPartitionNamesNoTxn doesn't handle max par…
Browse files Browse the repository at this point in the history
…am properly (Adam Szita, reviewed by Sergio Pena)
  • Loading branch information
szlta authored and Sergio Pena committed Feb 7, 2018
1 parent acc62e3 commit fa9a389
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2741,6 +2741,9 @@ private PartitionValuesResponse getDistinctValuesForPartitionsNoTxn(String dbNam

private List<String> getPartitionNamesNoTxn(String dbName, String tableName, short max) {
List<String> pns = new ArrayList<>();
if (max == 0) {
return pns;
}
dbName = normalizeIdentifier(dbName);
tableName = normalizeIdentifier(tableName);
Query query =
Expand All @@ -2749,6 +2752,7 @@ private List<String> getPartitionNamesNoTxn(String dbName, String tableName, sho
+ "order by partitionName asc");
query.declareParameters("java.lang.String t1, java.lang.String t2");
query.setResult("partitionName");

if (max > 0) {
query.setRange(0, max);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ public enum ConfVars {
"The special string _HOST will be replaced automatically with the correct host name."),
LIMIT_PARTITION_REQUEST("metastore.limit.partition.request",
"hive.metastore.limit.partition.request", -1,
"This limits the number of partitions that can be requested from the metastore for a given table.\n" +
"This limits the number of partitions (whole partition objects) that can be requested " +
"from the metastore for a give table. MetaStore API methods using this are: \n" +
"get_partitions, \n" +
"get_partitions_with_auth, \n" +
"get_partitions_by_filter, \n" +
"get_partitions_by_expr.\n" +
"The default value \"-1\" means no limit."),
LOG4J_FILE("metastore.log4j.file", "hive.log4j.file", "",
"Hive log4j configuration file.\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,14 +1040,10 @@ public void testListPartitionNames() throws Exception {
assertCorrectPartitionNames(partitionNames, testValues.subList(0, 2),
Lists.newArrayList("yyyy", "mm", "dd"));


//TODO: surprisingly listPartitionNames returns everything when 0 parts are requested
partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, (short)0);
assertFalse(partitionNames.isEmpty());
assertCorrectPartitionNames(partitionNames, testValues, Lists.newArrayList("yyyy", "mm",
"dd"));
assertTrue(partitionNames.isEmpty());

//TODO: surprisingly listPartitionNames doesn't fail when >100 parts are requested
//This method does not depend on MetastoreConf.LIMIT_PARTITION_REQUEST setting:
partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, (short)101);
assertCorrectPartitionNames(partitionNames, testValues, Lists.newArrayList("yyyy", "mm",
"dd"));
Expand Down

0 comments on commit fa9a389

Please sign in to comment.