diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index 3d1c67f97c6ab3f85b91a369c956047cfd20fd9e..6498fe560306d7776432d11cb6b5260cd99cf30a 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -2741,6 +2741,9 @@ private PartitionValuesResponse getDistinctValuesForPartitionsNoTxn(String dbNam private List getPartitionNamesNoTxn(String dbName, String tableName, short max) { List pns = new ArrayList<>(); + if (max == 0) { + return pns; + } dbName = normalizeIdentifier(dbName); tableName = normalizeIdentifier(tableName); Query query = @@ -2749,6 +2752,7 @@ private PartitionValuesResponse getDistinctValuesForPartitionsNoTxn(String dbNam + "order by partitionName asc"); query.declareParameters("java.lang.String t1, java.lang.String t2"); query.setResult("partitionName"); + if (max > 0) { query.setRange(0, max); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java index dba68ac38f8e8a8a8080fd675059233a2da86e70..5ef8d7aece0ab7ae04013bf7624b3cd6957ed6b6 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java @@ -528,7 +528,12 @@ public static ConfVars getMetaConf(String name) { "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" + 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 f4fa73beddf2f28ac0addcd6aaaef7d8dead16c9..fdabbe4bdaaa90f6e3a2d2f8b0726f32bbc50ac3 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 @@ -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"));