Skip to content

Commit 8a97567

Browse files
committed
fix ut - 2
1 parent f236f05 commit 8a97567

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ void alterPartition(List<String> oldPartitionVals, Partition newPartition, boole
188188
"Partition with partition values " + Arrays.toString(oldPartitionVals.toArray()) + " is not found.");
189189
}
190190
if (!oldPartition.getDbName().equals(newPartition.getDbName())) {
191-
throw new InvalidOperationException("Db name cannot be altered.");
191+
throw new MetaException("Db name cannot be altered.");
192192
}
193193
if (!oldPartition.getTableName().equals(newPartition.getTableName())) {
194-
throw new InvalidOperationException("Table name cannot be altered.");
194+
throw new MetaException("Table name cannot be altered.");
195195
}
196196
if (isRename) {
197197
newPartition.getSd().setLocation(oldPartition.getSd().getLocation());

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ public void shutdown() {
488488
pm.close();
489489
pm = null;
490490
}
491+
cachedImpls.clear();
491492
}
492493

493494
/**
@@ -525,25 +526,25 @@ public <T> T unwrap(Class<T> iface) {
525526
throw new IllegalArgumentException("Unable to unwrap the store as " + iface);
526527
}
527528
String implClassName = conf.get("metastore." + descriptor.alias() + ".store.impl", "");
529+
T simpl;
528530
T impl = (T) cachedImpls.get(iface);
529531
if (impl != null &&
530532
(StringUtils.isEmpty(implClassName) || impl.getClass().getName().equals(implClassName))) {
531-
return impl;
532-
}
533-
534-
Class<?> ifaceImpl = descriptor.defaultImpl();
535-
if (StringUtils.isNotEmpty(implClassName)) {
536-
ifaceImpl = conf.getClass(implClassName, ifaceImpl);
533+
simpl = impl;
534+
} else {
535+
Class<?> ifaceImpl = descriptor.defaultImpl();
536+
if (StringUtils.isNotEmpty(implClassName)) {
537+
ifaceImpl = conf.getClass(implClassName, ifaceImpl);
538+
}
539+
simpl = (T) JavaUtils.newInstance(ifaceImpl);
540+
cachedImpls.put(iface, simpl);
537541
}
538-
T simpl = (T) JavaUtils.newInstance(ifaceImpl);
539-
List<Query> trackOpenedQueries = new LinkedList<>();
542+
List<Query> openQueries = new LinkedList<>();
540543
if (simpl instanceof RawStoreAware rsa) {
541544
rsa.setBaseStore(this);
542-
rsa.setPersistentManager(PersistenceManagerProxy.getProxy(pm, trackOpenedQueries));
545+
rsa.setPersistentManager(PersistenceManagerProxy.getProxy(pm, openQueries));
543546
}
544-
impl = TransactionHandler.getProxy(iface, new TransactionHandler<>(this, simpl, trackOpenedQueries));
545-
cachedImpls.put(iface, impl);
546-
return impl;
547+
return TransactionHandler.getProxy(iface, new TransactionHandler<>(this, simpl, openQueries));
547548
}
548549

549550
@Override
@@ -7498,7 +7499,6 @@ private boolean isCurrentStatsValidForTheQuery(MTable tbl, String queryValidWrit
74987499
* ~ COLUMN_STATE_ACCURATE(CSA) state is true
74997500
* ~ Isolation-level (snapshot) compliant with the query
75007501
* @param queryValidWriteIdList valid writeId list of the query
7501-
* @Precondition "part" should be retrieved from the PARTITIONS table.
75027502
*/
75037503
// TODO: move to somewhere else
75047504
public static boolean isCurrentStatsValidForTheQuery(

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metastore/TransactionHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import org.apache.hadoop.hive.metastore.RawStore;
3232

33-
public record TransactionHandler<T> (RawStore rs, T simpl, List<Query> closeQueriesAfterUse)
33+
public record TransactionHandler<T> (RawStore rs, T simpl, List<Query> openQueries)
3434
implements InvocationHandler {
3535

3636
@SuppressWarnings("unchecked")
@@ -61,10 +61,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
6161
if (openTxn && !success) {
6262
rs.rollbackTransaction();
6363
}
64-
for (Query q : closeQueriesAfterUse) {
64+
for (Query q : openQueries) {
6565
q.closeAll();
6666
}
67-
closeQueriesAfterUse.clear();
67+
openQueries.clear();
6868
}
6969
}
7070
}

standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ public void testRenamePartitionNullTblName() throws Exception {
11581158
}
11591159

11601160
@Test(expected = InvalidOperationException.class)
1161+
@ConditionalIgnoreOnSessionHiveMetastoreClient
11611162
public void testRenamePartitionChangeTblName() throws Exception {
11621163
List<List<String>> oldValues = createTable4PartColsParts(client);
11631164
List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1);
@@ -1169,6 +1170,7 @@ public void testRenamePartitionChangeTblName() throws Exception {
11691170
}
11701171

11711172
@Test(expected = InvalidOperationException.class)
1173+
@ConditionalIgnoreOnSessionHiveMetastoreClient
11721174
public void testRenamePartitionChangeDbName() throws Exception {
11731175
List<List<String>> oldValues = createTable4PartColsParts(client);
11741176
List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1);

0 commit comments

Comments
 (0)