Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

package org.apache.iceberg.mr;

import java.io.Closeable;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.CatalogUtil;
import org.apache.iceberg.PartitionSpec;
Expand Down Expand Up @@ -111,7 +113,13 @@ private static Table loadTable(Configuration conf, String tableIdentifier, Strin

if (catalog.isPresent()) {
Preconditions.checkArgument(tableIdentifier != null, "Table identifier not set");
return catalog.get().loadTable(TableIdentifier.parse(tableIdentifier));
try {
return catalog.get().loadTable(TableIdentifier.parse(tableIdentifier));
} finally {
if (catalog.get() instanceof Closeable closeable) {
IOUtils.closeQuietly(closeable);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is a copy of apache/iceberg/mr/.../Catalogs.java, and the upstream version does not have the equivalent of this change. Why does Apache Iceberg justify the current implementation? Or it is still a problem on upstream, but no MapReduce users are interested in the warning message.

The current implementation is likely to work. For future reference, I'm also curious about what the to-be solution is.

Copy link
Member

@deniskuzZ deniskuzZ Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid logical fallback and close resource when required?

private static Table loadTable(Configuration conf, String tableIdentifier, String tableLocation,
                               String catalogName) {
    Optional<Catalog> catalog = loadCatalog(conf, catalogName);

    if (catalog.isPresent()) {
        Preconditions.checkArgument(tableIdentifier != null, "Table identifier not set");
        try {
            return catalog.get().loadTable(TableIdentifier.parse(tableIdentifier));
        } finally {
            if (catalog.get() instanceof Closeable closeable) {
              IOUtils.closeQuietly(closeable);
            }
        }
    }
    ....
}

}

Preconditions.checkArgument(tableLocation != null, "Table location not set");
Expand Down