JingsongLi commented on code in PR #887:
URL: https://github.com/apache/incubator-paimon/pull/887#discussion_r1174490523
##########
paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java:
##########
@@ -97,18 +100,31 @@ public class HiveCatalog extends AbstractCatalog {
private final String clientClassName;
private final IMetaStoreClient client;
+ private LocationHelper locationHelper;
+
public HiveCatalog(FileIO fileIO, HiveConf hiveConf, String
clientClassName) {
- super(fileIO);
- this.hiveConf = hiveConf;
- this.clientClassName = clientClassName;
- this.client = createClient(hiveConf, clientClassName);
+ this(fileIO, hiveConf, clientClassName, Collections.emptyMap());
}
public HiveCatalog(
FileIO fileIO, HiveConf hiveConf, String clientClassName,
Map<String, String> options) {
super(fileIO, options);
this.hiveConf = hiveConf;
this.clientClassName = clientClassName;
+
+ boolean needLocationInProperties =
+ hiveConf.getBoolean(
+ LOCATION_IN_PROPERTIES.key(),
LOCATION_IN_PROPERTIES.defaultValue());
+ if (needLocationInProperties) {
+ locationHelper = new TBPropertiesLocationHelper(hiveConf);
+ } else {
+ // set the warehouse location to the hiveConf
+ String warehouse = hiveConf.get(CatalogOptions.WAREHOUSE.key());
+ hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname,
warehouse);
+
+ locationHelper = new StorageLocationHelper(hiveConf);
Review Comment:
We can put these two lines to the constructor of `StorageLocationHelper`.
```
String warehouse = hiveConf.get(CatalogOptions.WAREHOUSE.key());
hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, warehouse);
```
##########
paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalogOptions.java:
##########
@@ -40,5 +40,12 @@ public final class HiveCatalogOptions {
.withDescription(
"File directory of the
core-site.xml、hdfs-site.xml、yarn-site.xml、mapred-site.xml. Currently, only
local file system paths are supported.");
+ public static final ConfigOption<Boolean> LOCATION_IN_PROPERTIES =
+ ConfigOptions.key("location-in-properties")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "setting the location in properties of hive
table/database, you can try configing 'location-in-properties'= 'true' if you
don't want that accessing the location of hive table/database by the filesystem
of hive,when using object store as the warehouse of hive catalog.");
Review Comment:
We should avoid single line that are too long
##########
paimon-common/src/main/java/org/apache/paimon/utils/LocationKeyExtractor.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.paimon.utils;
+
+import java.util.Properties;
+
+/**
+ * declaring the name of the key in the parameters of the Hive metastore
table, which indicates
+ * where the Paimon table is stored.
+ */
+public class LocationKeyExtractor {
Review Comment:
Can we merge this class into `TBPropertiesLocationHelper`?
##########
paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalogFactory.java:
##########
@@ -69,7 +69,7 @@ public Catalog create(FileIO fileIO, Path warehouse,
CatalogContext context) {
// always using user-set parameters overwrite hive-site.xml parameters
context.options().toMap().forEach(hiveConf::set);
hiveConf.set(HiveConf.ConfVars.METASTOREURIS.varname, uri);
- hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname,
warehouse.toUri().toString());
+ hiveConf.set(CatalogOptions.WAREHOUSE.key(),
warehouse.toUri().toString());
Review Comment:
Can we delete this line?
We can just pass warehouse to `HiveCatalog`.
And just pass warehouse to `LoctionHelper`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]