diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java index da6d19cf3198e..f518fc14996c2 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java @@ -22,7 +22,6 @@ import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.Partition; -import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +35,7 @@ import java.util.List; import java.util.Map; +import static org.apache.hadoop.hive.metastore.Warehouse.LOG; import static org.apache.hadoop.hive.metastore.Warehouse.makePartName; import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.makePartNameMatcher; @@ -121,8 +121,8 @@ List addPartitions(List partitions, boolean ifNotExists) * {@link MetaStoreUtils#getPvals(List, Map)} */ List getPartitionsByPartitionVals(List partialPartVals) throws MetaException { - if (MetaStoreUtils.arePartValsEmpty(partialPartVals)) { - return new ArrayList<>(parts.values()); + if (partialPartVals == null || partialPartVals.isEmpty()) { + throw new MetaException("Partition partial vals cannot be null or empty"); } String partNameMatcher = makePartNameMatcher(tTable, partialPartVals, ".*"); List matchedPartitions = new ArrayList<>(); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java index 9c9d7db641304..4341fd914228e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java @@ -1118,7 +1118,7 @@ public List listPartitionsWithAuthInfo(String catName, String dbName, String tableName, List partialPvals, int maxParts, String userName, List groupNames) throws TException { org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tableName); - if (table == null || partialPvals == null) { + if (table == null) { //(assume) not a temp table - Try underlying client return super.listPartitionsWithAuthInfo(catName, dbName, tableName, partialPvals, maxParts, userName, groupNames); @@ -1179,7 +1179,7 @@ public List listPartitionNames(String catName, String dbName, String tbl public List listPartitionNames(String catName, String dbName, String tblName, List partVals, int maxParts) throws TException { org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName); - if (table == null || partVals == null) { + if (table == null) { return super.listPartitionNames(catName, dbName, tblName, partVals, maxParts); } TempTable tt = getPartitionedTempTable(table); @@ -1295,7 +1295,7 @@ public List listPartitions(String catName, String dbName, String tblN public List listPartitions(String catName, String dbName, String tblName, List partVals, int maxParts) throws TException { org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName); - if (table == null || partVals == null) { + if (table == null) { return super.listPartitions(catName, dbName, tblName, partVals, maxParts); } TempTable tt = getPartitionedTempTable(table); diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 8d426ca7e400a..f95d3dd16e168 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -3100,9 +3100,6 @@ public List listPartitionNames(String catName, String db_name, String tb protected List listPartitionNamesInternal(String catName, String db_name, String tbl_name, List part_vals, int max_parts) throws TException { - if (db_name == null || tbl_name == null || part_vals == null) { - throw new MetaException("Database name/Table name/partition values should not be null"); - } return client.get_partition_names_ps(prependCatalogToDbName(catName, db_name, conf), tbl_name, part_vals, shrinkMaxtoShort(max_parts)); } diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java index bd2bdfe02dd25..9c66c1ae63dae 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java @@ -6620,8 +6620,13 @@ private List get_partitions_ps_with_auth(final String db_name, List ret = null; Exception ex = null; try { - checkLimitNumberOfPartitionsByPs(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], - tbl_name, args.getPart_vals(), args.getMax()); + if (args.getPart_vals() != null) { + checkLimitNumberOfPartitionsByPs(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], + tbl_name, args.getPart_vals(), args.getMax()); + } else { + checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], + tbl_name, NO_FILTER_STRING, args.getMax()); + } authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name); ret = getMS().listPartitionsPsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, args); diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index ec5612056d716..5ea24bc75352b 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -3840,9 +3840,6 @@ private List getPartitionNamesNoTxn(String catName, String dbName, Strin @Override public int getNumPartitionsByPs(String catName, String dbName, String tblName, List partVals) throws MetaException, NoSuchObjectException { - if (MetaStoreUtils.arePartValsEmpty(partVals)) { - return getNumPartitionsByFilter(catName, dbName, tblName, HMSHandler.NO_FILTER_STRING); - } catName = normalizeIdentifier(catName); dbName = normalizeIdentifier(dbName); @@ -4008,10 +4005,6 @@ protected List getJdoResult(GetHelper> ctx) @Override public List listPartitionNamesPs(String catName, String dbName, String tableName, List part_vals, short max_parts) throws MetaException, NoSuchObjectException { - if (MetaStoreUtils.arePartValsEmpty(part_vals)) { - return listPartitionNames(catName, dbName, tableName, max_parts); - } - List partitionNames = new ArrayList<>(); boolean success = false; diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java index 7086d441f5c2e..abaf28217cae0 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java @@ -425,13 +425,10 @@ public void testListPartitionsByValues() throws Exception { assertEquals(0, partitions.size()); } - @Test + @Test(expected = MetaException.class) public void testListPartitionsByValuesNoVals() throws Exception { createTable3PartCols1Part(client); - List partitions = client.listPartitions(DB_NAME, TABLE_NAME, - Lists.newArrayList(), (short)-1); - assertEquals(1, partitions.size()); - assertPartitionsHaveCorrectParams(partitions); + client.listPartitions(DB_NAME, TABLE_NAME, Lists.newArrayList(), (short)-1); } @Test(expected = MetaException.class) @@ -755,14 +752,11 @@ public void testListPartitionsWithAuthByValues() throws Exception { assertTrue(partitions.isEmpty()); } - @Test + @Test(expected = MetaException.class) public void testListPartitionsWithAuthByValuesNoVals() throws Exception { - List> partValues = createTable4PartColsPartsAuthOn(client).testValues; - List partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists - .newArrayList(), (short)-1, "", Lists.newArrayList()); - assertEquals(4, partitions.size()); - assertPartitionsHaveCorrectValues(partitions, partValues); - assertPartitionsHaveCorrectParams(partitions); + createTable4PartColsPartsAuthOn(client); + client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists + .newArrayList(), (short)-1, "", Lists.newArrayList()); } @@ -1436,13 +1430,10 @@ public void testListPartitionNamesByValuesLowPartCount() throws Exception { Lists.newArrayList("yyyy", "mm", "dd")); } - @Test + @Test(expected = MetaException.class) public void testListPartitionNamesByValuesNoPartVals() throws Exception { - List> testValues = createTable4PartColsParts(client).testValues; - List partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, - Lists.newArrayList(), (short)-1); - assertTrue(partitionNames.size() == 4); - assertCorrectPartitionNames(partitionNames, testValues, Lists.newArrayList("yyyy", "mm", "dd")); + createTable4PartColsParts(client); + client.listPartitionNames(DB_NAME, TABLE_NAME, Lists.newArrayList(), (short)-1); } @Test(expected = MetaException.class)