Skip to content

Commit

Permalink
Fix hive load hive_site_path and hdfs_site_path too late (apache#7017)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricJoy2048 authored and Thomas-HuWei committed Jul 10, 2024
1 parent 7d53592 commit 60b9c72
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.seatunnel.api.configuration.Option;
import org.apache.seatunnel.api.configuration.Options;
import org.apache.seatunnel.api.configuration.ReadonlyConfig;
import org.apache.seatunnel.connectors.seatunnel.file.config.BaseSinkConfig;
import org.apache.seatunnel.connectors.seatunnel.hive.config.HiveConfig;

import org.apache.commons.lang3.StringUtils;
Expand All @@ -31,6 +32,7 @@
import com.google.common.collect.ImmutableList;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -80,6 +82,32 @@ protected Configuration loadHiveBaseHadoopConfig(ReadonlyConfig readonlyConfig)
}
});
}
readonlyConfig
.getOptional(BaseSinkConfig.HDFS_SITE_PATH)
.ifPresent(
hdfsSitePath -> {
try {
configuration.addResource(new File(hdfsSitePath).toURI().toURL());
} catch (IOException e) {
log.warn(
"Error adding Hadoop resource {}, resource was not added",
hdfsSitePath,
e);
}
});
readonlyConfig
.getOptional(HiveConfig.HIVE_SITE_PATH)
.ifPresent(
hiveSitePath -> {
try {
configuration.addResource(new File(hiveSitePath).toURI().toURL());
} catch (IOException e) {
log.warn(
"Error adding Hadoop resource {}, resource was not added",
hiveSitePath,
e);
}
});
// Try to load from hadoopConf
Optional<Map<String, String>> hadoopConf =
readonlyConfig.getOptional(HiveConfig.HADOOP_CONF);
Expand Down

0 comments on commit 60b9c72

Please sign in to comment.