Skip to content

[SPARK-56764][SQL] Add spark.jars to SharedState.jarClassLoader for persistent UDF resolution#55869

Open
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-56764-udf-classloader
Open

[SPARK-56764][SQL] Add spark.jars to SharedState.jarClassLoader for persistent UDF resolution#55869
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-56764-udf-classloader

Conversation

@yadavay-amzn
Copy link
Copy Markdown

What changes were proposed in this pull request?

Add jars from spark.jars to SharedState.jarClassLoader during initialization.

Why are the changes needed?

When a persistent UDF is created via CREATE FUNCTION ... AS 'com.test.HelloUDF' (without USING JAR), the function metadata is stored in the catalog with empty resources. After ThriftServer restart, loadFunctionResources is a no-op and makeFunctionBuilder fails with CANNOT_LOAD_FUNCTION_CLASS because Utils.classIsLoadable returns false.

The jar is on the classpath via spark.jars, but SharedState.jarClassLoader is created empty and relies on parent classloader delegation to reach it. This delegation is not reliable in ThriftServer's thread pool threads.

The fix explicitly adds spark.jars to jarClassLoader so UDF classes are loadable regardless of parent delegation.

Does this PR introduce any user-facing change?

Yes. Persistent UDFs registered without USING JAR will now resolve correctly after ThriftServer restart when the jar is specified via spark.jars.

How was this patch tested?

Added test in SharedStateSuite verifying that spark.jars appear in jarClassLoader.getURLs.

Was this patch authored or co-authored using generative AI tooling?

Yes

@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-56764-udf-classloader branch from 385aac5 to 2c6d8e4 Compare May 14, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant