Skip to content
Merged
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 @@ -24,9 +24,10 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.java.util.common.RE;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.utils.DynamicConfigProviderUtils;
import org.apache.iceberg.CatalogUtil;
import org.apache.iceberg.aws.glue.GlueCatalog;
import org.apache.iceberg.catalog.Catalog;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -95,7 +96,21 @@ private Catalog setupGlueCatalog()
{
// We are not passing any hadoop config, third parameter is null
catalogProperties.put("type", TYPE_KEY);
catalog = CatalogUtil.buildIcebergCatalog(CATALOG_NAME, catalogProperties, null);

// AWS Glue catalog internally uses reflection to locate certain classes from the iceberg-aws dependency.
// These classes are not available in the current context class loader, and so we explicitly set the context class loader to the system classloader.
ClassLoader currCtxClassloader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
catalog = new GlueCatalog();
catalog.initialize(CATALOG_NAME, catalogProperties);
}
catch (Exception e) {
throw new RE(e, "Failed to initialize Glue catalog");
}
finally {
Thread.currentThread().setContextClassLoader(currCtxClassloader);
}
return catalog;
}

Expand Down
Loading