openinx commented on a change in pull request #1659:
URL: https://github.com/apache/iceberg/pull/1659#discussion_r512372385
##########
File path: flink/src/main/java/org/apache/iceberg/flink/FlinkCatalogFactory.java
##########
@@ -144,6 +144,11 @@ private static Configuration mergeHiveConf(Configuration
hadoopConf, String hive
URL configFile =
CatalogLoader.class.getClassLoader().getResource("hive-site.xml");
if (configFile != null) {
newConf.addResource(configFile);
+ } else {
+ // If can not find hive-site.xml from classpath, then try to load
resource from system env.
+ // this would be useful if don't set `hive-conf-dir` key in ddl.
+ String hiveHome = System.getenv("HIVE_HOME");
+ newConf.addResource(new Path(hiveHome + "/conf/hive-site.xml"));
Review comment:
BTW, I'd prefer to split this `mergeHiveConf` into three code blocks,
rather than put them into the complex if-else-if . That makes the code more
clear:
```java
private static Configuration mergeHiveConf(Configuration hadoopConf,
String hiveConfDir) {
Configuration newConf = new Configuration(hadoopConf);
// Approach : Parse the hive-site.xml from hive-conf-dir if possible.
if (!Strings.isNullOrEmpty(hiveConfDir)) {
Preconditions.checkState(Files.exists(Paths.get(hiveConfDir,
"hive-site.xml")),
"There should be a hive-site.xml file under the directory %s",
hiveConfDir);
newConf.addResource(new Path(hiveConfDir, "hive-site.xml"));
return newConf;
}
// Approach 2: Parse the hive-site.xml from HIVE_HOME system environment
variable.
String hiveHome = System.getenv("HIVE_HOME");
if (Files.exists(Paths.get(hiveHome, "conf/hive-site.xml"))) {
newConf.addResource(new Path(hiveHome, "conf/hive-site.xml"));
return newConf;
}
// Approach 3: Parse the hive-site.xml from classpath
URL configFile =
CatalogLoader.class.getClassLoader().getResource("hive-site.xml");
if (configFile != null) {
newConf.addResource(configFile);
}
return newConf;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]