xuefuz commented on a change in pull request #8616: [FLINK-12718][hive] allow
users to specify hive-site.xml location to configure hive metastore client in
HiveCatalog
URL: https://github.com/apache/flink/pull/8616#discussion_r291317963
##########
File path:
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
##########
@@ -109,27 +114,51 @@
private HiveMetastoreClientWrapper client;
- public HiveCatalog(String catalogName, String hivemetastoreURI) {
- this(catalogName, DEFAULT_DB, getHiveConf(hivemetastoreURI));
+ public HiveCatalog(String catalogName, @Nullable String
defaultDatabase, @Nullable String hiveSiteFilePath) {
+ this(catalogName,
+ defaultDatabase == null ? DEFAULT_DB : defaultDatabase,
+ getHiveConf(hiveSiteFilePath));
}
- public HiveCatalog(String catalogName, HiveConf hiveConf) {
- this(catalogName, DEFAULT_DB, hiveConf);
+ public HiveCatalog(String catalogName, @Nullable String
defaultDatabase, @Nullable URL hiveSiteUrl) {
+ this(catalogName,
+ defaultDatabase == null ? DEFAULT_DB : defaultDatabase,
+ getHiveConf(hiveSiteUrl));
}
- public HiveCatalog(String catalogName, String defaultDatabase, HiveConf
hiveConf) {
- super(catalogName, defaultDatabase);
- this.hiveConf = checkNotNull(hiveConf, "hiveConf cannot be
null");
+ public HiveCatalog(String catalogName, @Nullable String
defaultDatabase, @Nullable HiveConf hiveConf) {
+ super(catalogName, defaultDatabase == null ? DEFAULT_DB :
defaultDatabase);
+
+ this.hiveConf = hiveConf == null ? getHiveConf("") : hiveConf;
LOG.info("Created HiveCatalog '{}'", catalogName);
}
- private static HiveConf getHiveConf(String hiveMetastoreURI) {
-
checkArgument(!StringUtils.isNullOrWhitespaceOnly(hiveMetastoreURI),
"hiveMetastoreURI cannot be null or empty");
+ private static HiveConf getHiveConf(String filePath) {
Review comment:
Nit: I think instead of having two overloaded getHiveConf(), we can have one
that convert string to URL and another that instantiates HiveConf. This might
make the code easier to read.
----------------------------------------------------------------
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]
With regards,
Apache Git Services