majin1102 commented on code in PR #4450: URL: https://github.com/apache/amoro/pull/4450#discussion_r4323856363
########## amoro-format-lance/src/main/java/org/apache/amoro/formats/lance/LanceHiveCatalog.java: ########## @@ -0,0 +1,161 @@ +/* + * 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.amoro.formats.lance; + +import org.apache.amoro.AmoroTable; +import org.apache.amoro.properties.CatalogMetaProperties; +import org.apache.amoro.table.TableIdentifier; +import org.apache.amoro.table.TableMetaStore; +import org.apache.amoro.utils.CatalogUtil; +import org.apache.arrow.memory.RootAllocator; +import org.apache.arrow.util.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.apache.hadoop.conf.Configuration; +import org.apache.iceberg.aliyun.AliyunProperties; +import org.apache.iceberg.aws.AwsClientProperties; +import org.apache.iceberg.aws.s3.S3FileIOProperties; +import org.lance.Dataset; +import org.lance.ReadOptions; +import org.lance.namespace.LanceNamespace; +import org.lance.namespace.hive3.Hive3Namespace; +import org.lance.namespace.hive3.Hive3NamespaceConfig; +import org.lance.namespace.model.DeregisterTableRequest; +import org.lance.namespace.model.DescribeTableRequest; +import org.lance.namespace.model.DescribeTableResponse; +import org.lance.namespace.model.DropTableRequest; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** Lance catalog backed by a Hive metastore; metadata is delegated to {@link Hive3Namespace}. */ +public class LanceHiveCatalog extends AbstractLanceCatalog { + + private static final String HIVE_METASTORE_URIS = "hive.metastore.uris"; + + /** Escape hatch for storage options Amoro does not model, e.g. MinIO's aws_allow_http. */ + private static final String STORAGE_OPTIONS_PREFIX = "lance.storage-options."; + + private final Map<String, String> catalogProperties; + + public LanceHiveCatalog( + String catalogName, Map<String, String> catalogProperties, TableMetaStore metaStore) { + super( + catalogName, + buildNamespace(catalogProperties, metaStore), + catalogPrefix(catalogProperties, Hive3NamespaceConfig.CATALOG_NAME)); + this.catalogProperties = new HashMap<>(catalogProperties); + } + + @Override + protected AmoroTable<?> openTable(String database, String table) { + DescribeTableResponse response = + namespace.describeTable(new DescribeTableRequest().id(tableId(database, table))); + return new LanceTable( + TableIdentifier.of(catalogName, database, table), + openDataset(response.getLocation()), + response.getProperties()); + } + + /** Purge deletes the table data; otherwise only the metastore entry is deregistered. */ + @Override + protected void dropInNamespace(String database, String table, boolean purge) { + if (purge) { + namespace.dropTable(new DropTableRequest().id(tableId(database, table))); Review Comment: [P1] Preserve storage options and surface failures when purging table data When credentials or a custom endpoint are configured only in the Amoro catalog (for example, a private S3/OSS bucket or MinIO), reads work through `storageOptions(catalogProperties, location)`, but this purge path does not use those options. In the pinned `lance-namespace-hive3:0.4.1` implementation, `doDropTable()` removes the HMS entry first, then `safeDropDataset()` calls `Dataset.drop(location, Collections.emptyMap())` and catches deletion exceptions, logging only a warning. Consequently, `dropTable(..., true)` can report success after removing the metadata while leaving the underlying data intact; retrying by table name then cannot clean it up because the HMS entry is gone. Please use the same resolved storage options as the read path for data deletion and propagate deletion failures instead of reporting a successful purge. A regression test should cover catalog-only credentials/custom endpoints and a failed data deletion. -- 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]
