From d04a2de3cc740b73a417300f253cab35bdefb096 Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Thu, 23 Nov 2023 19:42:46 +0800 Subject: [PATCH] [fix](hms) fix compatibility issue of hive metastore client (#27327) For hive version lower than 2.3.7, there is no enum ClientCapability.INSERT_ONLY_TABLES. So if we send this enum to the server side, the server side will get a null, and this will cause some undefined behavior, eg, failed to get tables infos from hms. --- .../hadoop/hive/metastore/HiveMetaStoreClient.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/fe/fe-core/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index b39bec7c96..ff85e31959 100644 --- a/fe/fe-core/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/fe/fe-core/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -343,11 +343,17 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable { hiveVersion = HiveVersionUtil.getVersion(conf.get(HMSProperties.HIVE_VERSION)); - version = MetastoreConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST) ? TEST_VERSION : VERSION; + // For hive 2.3.7, there is no ClientCapability.INSERT_ONLY_TABLES + if (hiveVersion == HiveVersion.V1_0 || hiveVersion == HiveVersion.V2_0 || hiveVersion == HiveVersion.V2_3) { + version = MetastoreConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST) ? TEST_VERSION : null; + } else { + version = MetastoreConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST) ? TEST_VERSION : VERSION; + } + filterHook = loadFilterHooks(); uriResolverHook = loadUriResolverHook(); fileMetadataBatchSize = MetastoreConf.getIntVar( - conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX); + conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX); String msUri = MetastoreConf.getVar(conf, ConfVars.THRIFT_URIS); localMetaStore = MetastoreConf.isEmbeddedMetaStore(msUri);