This is an automated email from the ASF dual-hosted git repository.

atul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ed53eda995 Fix class loading issue for glue catalog (#18016)
2ed53eda995 is described below

commit 2ed53eda9959617c190d6ef2b18565d3ac50d603
Author: Atul Mohan <[email protected]>
AuthorDate: Wed May 21 10:19:05 2025 -0700

    Fix class loading issue for glue catalog (#18016)
---
 .../druid/iceberg/input/GlueIcebergCatalog.java       | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/GlueIcebergCatalog.java
 
b/extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/GlueIcebergCatalog.java
index 9919ac7f847..5dfcebb062f 100644
--- 
a/extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/GlueIcebergCatalog.java
+++ 
b/extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/GlueIcebergCatalog.java
@@ -24,9 +24,10 @@ import com.fasterxml.jackson.annotation.JsonCreator;
 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;
@@ -95,7 +96,21 @@ public class GlueIcebergCatalog extends IcebergCatalog
   {
     // 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;
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to