1
0

[HUDI-2233] Use HMS To Sync Hive Meta For Spark Sql (#3387)

This commit is contained in:
pengzhiwei
2021-08-05 21:57:22 +08:00
committed by GitHub
parent 1df5ded433
commit 0dcd6a8fca
10 changed files with 69 additions and 26 deletions

View File

@@ -22,13 +22,13 @@ import org.apache.hudi.common.fs.FSUtils;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
import org.apache.hudi.common.util.Option;
import org.apache.hudi.common.util.StringUtils;
import org.apache.hudi.hive.util.HiveSchemaUtil;
import org.apache.hudi.sync.common.AbstractSyncHoodieClient;
import org.apache.hudi.hive.ddl.DDLExecutor;
import org.apache.hudi.hive.ddl.HMSDDLExecutor;
import org.apache.hudi.hive.ddl.HiveQueryDDLExecutor;
import org.apache.hudi.hive.ddl.HiveSyncMode;
import org.apache.hudi.hive.ddl.JDBCExecutor;
import org.apache.hudi.hive.util.HiveSchemaUtil;
import org.apache.hudi.sync.common.AbstractSyncHoodieClient;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.conf.HiveConf;
@@ -69,14 +69,15 @@ public class HoodieHiveClient extends AbstractSyncHoodieClient {
// disable jdbc and depend on metastore client for all hive registrations
try {
if (!StringUtils.isNullOrEmpty(cfg.syncMode)) {
switch (cfg.syncMode.toLowerCase()) {
case "hms":
HiveSyncMode syncMode = HiveSyncMode.of(cfg.syncMode);
switch (syncMode) {
case HMS:
ddlExecutor = new HMSDDLExecutor(configuration, cfg, fs);
break;
case "hiveql":
case HIVEQL:
ddlExecutor = new HiveQueryDDLExecutor(cfg, fs, configuration);
break;
case "jdbc":
case JDBC:
ddlExecutor = new JDBCExecutor(cfg, fs);
break;
default:

View File

@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hudi.hive.ddl;
import java.util.Locale;
public enum HiveSyncMode {
/**
* The HMS mode use the hive meta client to sync metadata.
*/
HMS,
/**
* The HIVEQL mode execute hive ql to sync metadata.
*/
HIVEQL,
/**
* The JDBC mode use hive jdbc to sync metadata.
*/
JDBC
;
public static HiveSyncMode of(String syncMode) {
return HiveSyncMode.valueOf(syncMode.toUpperCase(Locale.ROOT));
}
}