Skip to content

Commit ec9a625

Browse files
authored
fix: Use thread context classloader to load Iceberg class in CometScanRule (#4609)
1 parent b5a97f8 commit ec9a625

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,14 @@ object CometScanRule extends Logging {
744744
* one iteration for better performance with large tables.
745745
*/
746746
def validateIcebergFileScanTasks(tasks: java.util.List[_]): IcebergTaskValidationResult = {
747-
// scalastyle:off classforname
748-
val contentScanTaskClass = Class.forName(IcebergReflection.ClassNames.CONTENT_SCAN_TASK)
749-
val contentFileClass = Class.forName(IcebergReflection.ClassNames.CONTENT_FILE)
750-
val fileScanTaskClass = Class.forName(IcebergReflection.ClassNames.FILE_SCAN_TASK)
751-
val unboundPredicateClass = Class.forName(IcebergReflection.ClassNames.UNBOUND_PREDICATE)
752-
// scalastyle:on classforname
747+
val contentScanTaskClass =
748+
IcebergReflection.loadClass(IcebergReflection.ClassNames.CONTENT_SCAN_TASK)
749+
val contentFileClass =
750+
IcebergReflection.loadClass(IcebergReflection.ClassNames.CONTENT_FILE)
751+
val fileScanTaskClass =
752+
IcebergReflection.loadClass(IcebergReflection.ClassNames.FILE_SCAN_TASK)
753+
val unboundPredicateClass =
754+
IcebergReflection.loadClass(IcebergReflection.ClassNames.UNBOUND_PREDICATE)
753755

754756
// Cache all method lookups outside the loop
755757
val fileMethod = contentScanTaskClass.getMethod("file")

0 commit comments

Comments
 (0)