Skip to content

Commit

Permalink
revert changes on clients
Browse files Browse the repository at this point in the history
  • Loading branch information
wecharyu committed Jun 12, 2024
1 parent 02ff2d5 commit 2d5eae8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -121,8 +121,8 @@ List<Partition> addPartitions(List<Partition> partitions, boolean ifNotExists)
* {@link MetaStoreUtils#getPvals(List, Map)}
*/
List<Partition> getPartitionsByPartitionVals(List<String> 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<Partition> matchedPartitions = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ public List<Partition> listPartitionsWithAuthInfo(String catName, String dbName,
String tableName, List<String> partialPvals, int maxParts, String userName,
List<String> 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);
Expand Down Expand Up @@ -1179,7 +1179,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
public List<String> listPartitionNames(String catName, String dbName, String tblName,
List<String> 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);
Expand Down Expand Up @@ -1295,7 +1295,7 @@ public List<Partition> listPartitions(String catName, String dbName, String tblN
public List<Partition> listPartitions(String catName, String dbName, String tblName,
List<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3100,9 +3100,6 @@ public List<String> listPartitionNames(String catName, String db_name, String tb

protected List<String> listPartitionNamesInternal(String catName, String db_name, String tbl_name,
List<String> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6620,8 +6620,13 @@ private List<Partition> get_partitions_ps_with_auth(final String db_name,
List<Partition> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3840,9 +3840,6 @@ private List<String> getPartitionNamesNoTxn(String catName, String dbName, Strin
@Override
public int getNumPartitionsByPs(String catName, String dbName, String tblName, List<String> partVals)
throws MetaException, NoSuchObjectException {
if (MetaStoreUtils.arePartValsEmpty(partVals)) {
return getNumPartitionsByFilter(catName, dbName, tblName, HMSHandler.NO_FILTER_STRING);
}

catName = normalizeIdentifier(catName);
dbName = normalizeIdentifier(dbName);
Expand Down Expand Up @@ -4008,10 +4005,6 @@ protected List<Partition> getJdoResult(GetHelper<List<Partition>> ctx)
@Override
public List<String> listPartitionNamesPs(String catName, String dbName, String tableName,
List<String> part_vals, short max_parts) throws MetaException, NoSuchObjectException {
if (MetaStoreUtils.arePartValsEmpty(part_vals)) {
return listPartitionNames(catName, dbName, tableName, max_parts);
}

List<String> partitionNames = new ArrayList<>();
boolean success = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Partition> 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)
Expand Down Expand Up @@ -755,14 +752,11 @@ public void testListPartitionsWithAuthByValues() throws Exception {
assertTrue(partitions.isEmpty());
}

@Test
@Test(expected = MetaException.class)
public void testListPartitionsWithAuthByValuesNoVals() throws Exception {
List<List<String>> partValues = createTable4PartColsPartsAuthOn(client).testValues;
List<Partition> 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());
}


Expand Down Expand Up @@ -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<List<String>> testValues = createTable4PartColsParts(client).testValues;
List<String> 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)
Expand Down

0 comments on commit 2d5eae8

Please sign in to comment.