dennishuo commented on code in PR #6428: URL: https://github.com/apache/iceberg/pull/6428#discussion_r1052903155
########## snowflake/src/main/java/org/apache/iceberg/snowflake/SnowflakeTableOperations.java: ########## @@ -0,0 +1,97 @@ +/* + * 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.iceberg.snowflake; + +import java.util.Map; +import org.apache.iceberg.BaseMetastoreTableOperations; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.exceptions.NoSuchTableException; +import org.apache.iceberg.io.FileIO; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.snowflake.entities.SnowflakeIdentifier; +import org.apache.iceberg.snowflake.entities.SnowflakeTableMetadata; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class SnowflakeTableOperations extends BaseMetastoreTableOperations { + + private static final Logger LOG = LoggerFactory.getLogger(SnowflakeTableOperations.class); + private final String catalogName; + + private final FileIO fileIO; + private final TableIdentifier tableIdentifier; + private final SnowflakeIdentifier snowflakeIdentifierForTable; + + private final SnowflakeClient snowflakeClient; + + private final Map<String, String> catalogProperties; + + protected SnowflakeTableOperations( + SnowflakeClient snowflakeClient, + FileIO fileIO, + Map<String, String> properties, + String catalogName, + TableIdentifier tableIdentifier) { + this.snowflakeClient = snowflakeClient; + this.fileIO = fileIO; + this.catalogProperties = properties; + this.catalogName = catalogName; + this.tableIdentifier = tableIdentifier; + this.snowflakeIdentifierForTable = + NamespaceHelpers.getSnowflakeIdentifierForTableIdentifier(tableIdentifier); + } + + @Override + public void doRefresh() { + LOG.debug("Getting metadata location for table {}", tableIdentifier); + String location = getTableMetadataLocation(); + Preconditions.checkState( + location != null && !location.isEmpty(), + "Got null or empty location %s for table %s", + location, + tableIdentifier); + refreshFromMetadataLocation(location); + } + + @Override + public FileIO io() { + return fileIO; + } + + @Override + protected String tableName() { + return tableIdentifier.toString(); Review Comment: Done. Also added a test case since it's not necessarily obvious at first glance whether all the plumbing is correct, but it's a bit messy since `tableName()` only has `protected` access in `BaseMetastoreTableOperations`. I ended up exposing a package-private version of the same thing that calls through. I guess if it's only used for logging purposes anyways though in BaseMetastoreTableOperations it might be okay to leave out the test case? Or if it's not too ugly we can keep the test case. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org