JingsongLi commented on code in PR #887: URL: https://github.com/apache/incubator-paimon/pull/887#discussion_r1174722850
########## docs/content/how-to/creating-catalogs.md: ########## @@ -127,6 +132,11 @@ After `spark-sql` is started, you can switch to the `default` database of the `p USE paimon.default; ``` +If you are using a object storage , and you don't want that the location of paimon table/database is accessed by the filesystem of hive, Review Comment: Maybe we can just copy these sentence to after `tab`? So both Flink and Spark can contain it. ########## paimon-hive/paimon-hive-common/src/main/java/org/apache/paimon/hive/LocationKeyExtractor.java: ########## @@ -0,0 +1,37 @@ +/* + * 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.hive; + +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 { + // special at the tbproperties with the name paimon_meta_location. + public static final String TBPROPERTIES_LOCATION_KEY = "paimon_meta_location"; + public static final String STORAGE_LOCATION_KEY = "location"; Review Comment: Can we remove this `STORAGE_LOCATION_KEY` and `getLocation`? They should be introduced in next PR instead of this PR. ########## paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/TBPropertiesLocationHelper.java: ########## @@ -0,0 +1,60 @@ +/* + * 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.hive; + +import org.apache.paimon.fs.FileIO; +import org.apache.paimon.fs.Path; + +import org.apache.hadoop.hive.metastore.api.Database; +import org.apache.hadoop.hive.metastore.api.Table; + +import java.io.IOException; +import java.util.HashMap; + +/** Helper for Setting Location in Hive Table Properties. */ +public final class TBPropertiesLocationHelper implements LocationHelper { + + public TBPropertiesLocationHelper() {} + + @Override + public void createPathIfRequired(Path path, FileIO fileIO) throws IOException { + if (!fileIO.exists(path)) { + fileIO.mkdirs(path); + } + } + + @Override + public void dropPathIfRequired(Path path, FileIO fileIO) throws IOException { + if (fileIO.exists(path)) { + fileIO.delete(path, true); + } + } + + @Override + public void specifyTableLocation(Table table, String location) { + table.getParameters().put(LocationKeyExtractor.TBPROPERTIES_LOCATION_KEY, location); + } + + @Override + public void specifyDatabaseLocation(Path path, Database database) { + HashMap<String, String> properties = new HashMap<>(); Review Comment: check if `database.getParameters != null`, `properties,putAll(database.getParameters)`? -- 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]
