[fix](hive external) support set hive version when create hive external table (#20622)
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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()));
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user