[fix](hive external) support set hive version when create hive external table (#20622)

This commit is contained in:
Chuang Li
2023-09-03 11:16:46 +08:00
committed by GitHub
parent e928868a4c
commit 8510af3a7f
3 changed files with 17 additions and 0 deletions

View File

@ -106,6 +106,12 @@ public class HiveTable extends Table {
}
copiedProps.remove(HMSProperties.HIVE_METASTORE_URIS);
hiveProperties.put(HMSProperties.HIVE_METASTORE_URIS, hiveMetaStoreUris);
// support multi hive version
String hiveVersion = copiedProps.get(HMSProperties.HIVE_VERSION);
if (!Strings.isNullOrEmpty(hiveVersion)) {
copiedProps.remove(HMSProperties.HIVE_VERSION);
hiveProperties.put(HMSProperties.HIVE_VERSION, hiveVersion);
}
// check auth type
String authType = copiedProps.get(HdfsResource.HADOOP_SECURITY_AUTHENTICATION);

View File

@ -2651,6 +2651,9 @@ public class InternalCatalog implements CatalogIf<Database> {
HiveConf hiveConf = new HiveConf();
hiveConf.set(HMSProperties.HIVE_METASTORE_URIS,
hiveTable.getHiveProperties().get(HMSProperties.HIVE_METASTORE_URIS));
if (!Strings.isNullOrEmpty(hiveTable.getHiveProperties().get(HMSProperties.HIVE_VERSION))) {
hiveConf.set(HMSProperties.HIVE_VERSION, hiveTable.getHiveProperties().get(HMSProperties.HIVE_VERSION));
}
PooledHiveMetaStoreClient client = new PooledHiveMetaStoreClient(hiveConf, 1);
if (!client.tableExists(hiveTable.getHiveDb(), hiveTable.getHiveTable())) {
throw new DdlException(String.format("Table [%s] dose not exist in Hive.", hiveTable.getHiveDbTable()));

View File

@ -18,6 +18,7 @@
package org.apache.doris.catalog;
import org.apache.doris.common.DdlException;
import org.apache.doris.datasource.property.constants.HMSProperties;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -77,4 +78,11 @@ public class HiveTableTest {
new HiveTable(1000, "hive_table", columns, properties);
Assert.fail("No exception throws.");
}
@Test()
public void testVersion() throws DdlException {
properties.put(HMSProperties.HIVE_VERSION, "2.1.2");
HiveTable table = new HiveTable(1000, "hive_table", columns, properties);
Assert.assertEquals("2.1.2", table.getHiveProperties().get(HMSProperties.HIVE_VERSION));
}
}