gaborkaszab commented on code in PR #11123:
URL: https://github.com/apache/iceberg/pull/11123#discussion_r1848981822


##########
core/src/main/java/org/apache/iceberg/CachingCatalog.java:
##########
@@ -145,22 +146,26 @@ public Table loadTable(TableIdentifier ident) {
     }
 
     if (MetadataTableUtils.hasMetadataTableName(canonicalized)) {

Review Comment:
   FWIW, as I see the RESTSessionCatalog does this the other way around: First 
tries to load the table as a regular table and then if that fails it tries to 
load it as a metadata table. 
https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java#L461
   I find that approach cleaner, but let me know what you think.



##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestCachingTableWithMetaTableName.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.spark.sql;
+
+import java.util.List;
+import org.apache.iceberg.Parameter;
+import org.apache.iceberg.Parameters;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.spark.CatalogTestBase;
+import org.apache.iceberg.spark.SparkCatalogConfig;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestTemplate;
+
+public class TestCachingTableWithMetaTableName extends CatalogTestBase {

Review Comment:
   I found that there is an existing test suite, TestCachingCatalog. Wouldn't 
it be cleaner to add test coverage there instead of to the Spark test suite?



##########
core/src/main/java/org/apache/iceberg/CachingCatalog.java:
##########
@@ -145,22 +146,26 @@ public Table loadTable(TableIdentifier ident) {
     }
 
     if (MetadataTableUtils.hasMetadataTableName(canonicalized)) {
-      TableIdentifier originTableIdentifier =
-          TableIdentifier.of(canonicalized.namespace().levels());
-      Table originTable = tableCache.get(originTableIdentifier, 
catalog::loadTable);
-
-      // share TableOperations instance of origin table for all metadata 
tables, so that metadata
-      // table instances are
-      // also refreshed as well when origin table instance is refreshed.
-      if (originTable instanceof HasTableOperations) {
-        TableOperations ops = ((HasTableOperations) originTable).operations();
-        MetadataTableType type = MetadataTableType.from(canonicalized.name());
-
-        Table metadataTable =
-            MetadataTableUtils.createMetadataTableInstance(
-                ops, catalog.name(), originTableIdentifier, canonicalized, 
type);
-        tableCache.put(canonicalized, metadataTable);
-        return metadataTable;
+      try {
+        TableIdentifier originTableIdentifier =
+            TableIdentifier.of(canonicalized.namespace().levels());
+        Table originTable = tableCache.get(originTableIdentifier, 
catalog::loadTable);
+
+        // share TableOperations instance of origin table for all metadata 
tables, so that metadata
+        // table instances are

Review Comment:
   nit: I know there was only an indentation change here, but there is an odd 
linebreak in this line



-- 
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

Reply via email to