You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2024/10/29 04:32:21 UTC
(paimon) branch master updated: [hive] Fix wrong construct for dlf metastore (#4387)
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 8ca7619cf [hive] Fix wrong construct for dlf metastore (#4387)
8ca7619cf is described below
commit 8ca7619cf6f0d3d1eb6c01258d8eed51f97faf36
Author: Jiao Mingye <35...@users.noreply.github.com>
AuthorDate: Tue Oct 29 12:32:15 2024 +0800
[hive] Fix wrong construct for dlf metastore (#4387)
---
.../hive/RetryingMetaStoreClientFactory.java | 44 ++++++++++++----------
.../hive/CustomConstructorMetastoreClient.java | 17 ++++++++-
.../apache/paimon/hive/Hive31CatalogITCase.java | 3 +-
3 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/RetryingMetaStoreClientFactory.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/RetryingMetaStoreClientFactory.java
index 2d62f56bc..0ac665fa4 100644
--- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/RetryingMetaStoreClientFactory.java
+++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/RetryingMetaStoreClientFactory.java
@@ -32,6 +32,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@@ -182,25 +183,30 @@ public class RetryingMetaStoreClientFactory {
Class<?> baseClass = Class.forName(clientClassName, false, JavaUtils.getClassLoader());
// Configuration.class or HiveConf.class
- Class<?> firstParamType = getProxyMethod.getParameterTypes()[0];
-
- Class<?>[] fullParams =
- new Class[] {firstParamType, HiveMetaHookLoader.class, Boolean.TYPE};
- Object[] fullParamValues =
- new Object[] {hiveConf, (HiveMetaHookLoader) (tbl -> null), Boolean.TRUE};
-
- for (int i = fullParams.length; i >= 1; i--) {
- try {
- baseClass.getConstructor(Arrays.copyOfRange(fullParams, 0, i));
- return (IMetaStoreClient)
- getProxyMethod.invoke(
- null,
- hiveConf,
- Arrays.copyOfRange(fullParams, 0, i),
- Arrays.copyOfRange(fullParamValues, 0, i),
- new ConcurrentHashMap<>(),
- clientClassName);
- } catch (NoSuchMethodException ignored) {
+ List<Class<?>> possibleFirstParamTypes =
+ Arrays.asList(getProxyMethod.getParameterTypes()[0], hiveConf.getClass());
+
+ for (Class<?> possibleFirstParamType : possibleFirstParamTypes) {
+ Class<?>[] fullParams =
+ new Class[] {
+ possibleFirstParamType, HiveMetaHookLoader.class, Boolean.TYPE
+ };
+ Object[] fullParamValues =
+ new Object[] {hiveConf, (HiveMetaHookLoader) (tbl -> null), Boolean.TRUE};
+
+ for (int i = fullParams.length; i >= 1; i--) {
+ try {
+ baseClass.getConstructor(Arrays.copyOfRange(fullParams, 0, i));
+ return (IMetaStoreClient)
+ getProxyMethod.invoke(
+ null,
+ hiveConf,
+ Arrays.copyOfRange(fullParams, 0, i),
+ Arrays.copyOfRange(fullParamValues, 0, i),
+ new ConcurrentHashMap<>(),
+ clientClassName);
+ } catch (NoSuchMethodException ignored) {
+ }
}
}
diff --git a/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/CustomConstructorMetastoreClient.java b/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/CustomConstructorMetastoreClient.java
index 35ff3f8bb..6b08f16d4 100644
--- a/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/CustomConstructorMetastoreClient.java
+++ b/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/CustomConstructorMetastoreClient.java
@@ -19,6 +19,7 @@
package org.apache.paimon.hive;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaHookLoader;
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
@@ -28,7 +29,7 @@ import org.apache.hadoop.hive.metastore.api.MetaException;
public class CustomConstructorMetastoreClient {
/**
- * A {@link HiveMetaStoreClient} to test custom Hive metastore client with (HiveConf,
+ * A {@link HiveMetaStoreClient} to test custom Hive metastore client with (Configuration,
* HiveMetaHookLoader) constructor.
*/
public static class TwoParameterConstructorMetastoreClient extends HiveMetaStoreClient
@@ -41,7 +42,7 @@ public class CustomConstructorMetastoreClient {
}
/**
- * A {@link HiveMetaStoreClient} to test custom Hive metastore client with (HiveConf)
+ * A {@link HiveMetaStoreClient} to test custom Hive metastore client with (Configuration)
* constructor.
*/
public static class OneParameterConstructorMetastoreClient extends HiveMetaStoreClient
@@ -51,4 +52,16 @@ public class CustomConstructorMetastoreClient {
super(conf);
}
}
+
+ /**
+ * A {@link HiveMetaStoreClient} to test custom Hive metastore client with (HiveConf)
+ * constructor.
+ */
+ public static class OtherParameterConstructorMetastoreClient extends HiveMetaStoreClient
+ implements IMetaStoreClient {
+
+ public OtherParameterConstructorMetastoreClient(HiveConf conf) throws MetaException {
+ super(conf);
+ }
+ }
}
diff --git a/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/Hive31CatalogITCase.java b/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/Hive31CatalogITCase.java
index 7b3ab5626..1a77723e9 100644
--- a/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/Hive31CatalogITCase.java
+++ b/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/Hive31CatalogITCase.java
@@ -89,7 +89,8 @@ public class Hive31CatalogITCase extends HiveCatalogITCaseBase {
EnvironmentSettings settings = EnvironmentSettings.newInstance().inBatchMode().build();
Class<?>[] customConstructorMetastoreClientClass = {
CustomConstructorMetastoreClient.TwoParameterConstructorMetastoreClient.class,
- CustomConstructorMetastoreClient.OneParameterConstructorMetastoreClient.class
+ CustomConstructorMetastoreClient.OneParameterConstructorMetastoreClient.class,
+ CustomConstructorMetastoreClient.OtherParameterConstructorMetastoreClient.class
};
for (Class<?> clazz : customConstructorMetastoreClientClass) {