openinx commented on a change in pull request #1659:
URL: https://github.com/apache/iceberg/pull/1659#discussion_r512525877
##########
File path: flink/src/main/java/org/apache/iceberg/flink/FlinkCatalogFactory.java
##########
@@ -134,17 +134,26 @@ protected Catalog createCatalog(String name, Map<String,
String> properties, Con
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.
Review comment:
nit: 'Approach' -> 'Approach 1'
##########
File path:
flink/src/test/java/org/apache/iceberg/flink/TestFlinkHiveCatalog.java
##########
@@ -76,6 +78,36 @@ public void testCreateCatalogWithHiveConfDir() throws
IOException {
checkSQLQuery(props, warehouseDir);
}
+ @Test
+ public void testCreateCatalogWithHiveHome() throws IOException {
+ File hiveHome = tempFolder.newFolder();
+ File hiveConfDir = new File(hiveHome, "conf");
+ hiveConfDir.mkdir();
+ File hiveSiteXML = new File(hiveConfDir, "hive-site.xml");
+ File warehouseDir = tempFolder.newFolder();
+
+ try (FileOutputStream fos = new FileOutputStream(hiveSiteXML)) {
+ Configuration newConf = new Configuration(hiveConf);
+ newConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, "file://" +
warehouseDir.getAbsolutePath());
+ newConf.writeXml(fos);
+ }
+ Assert.assertTrue("hive-site.xml should be created now.",
Files.exists(hiveSiteXML.toPath()));
+
+ final Map<String, String> originalEnv = System.getenv();
+ final Map<String, String> newEnv = new HashMap<>(originalEnv);
+
+ newEnv.put("HIVE_HOME", hiveHome.getAbsolutePath());
+ CommonTestUtils.setEnv(newEnv);
+
+ // Construct the catalog attributions.
+ Map<String, String> props = Maps.newHashMap();
+ props.put("type", "iceberg");
+ props.put(FlinkCatalogFactory.ICEBERG_CATALOG_TYPE, "hive");
+ props.put(FlinkCatalogFactory.HIVE_URI,
FlinkCatalogTestBase.getURI(hiveConf));
+
+ checkSQLQuery(props, warehouseDir);
Review comment:
I think we need a `try-finally` block to revert back to use the
`originalEnv`.
----------------------------------------------------------------
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]