Skip to content

[SPARK-50698][SQL] Refactor CreateUserDefinedFunction command to extend from UnaryRunnableCommand - #58344

Open
zahed1994 wants to merge 14 commits into
apache:masterfrom
zahed1994:SPARK-50698-unary-runnable-udf-command
Open

[SPARK-50698][SQL] Refactor CreateUserDefinedFunction command to extend from UnaryRunnableCommand#58344
zahed1994 wants to merge 14 commits into
apache:masterfrom
zahed1994:SPARK-50698-unary-runnable-udf-command

Conversation

@zahed1994

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR refactors CreateUserDefinedFunctionCommand (and concrete subclasses such as CreateSQLFunctionCommand) to extend from UnaryRunnableCommand taking child: LogicalPlan instead of LeafRunnableCommand.

Specifically:

  • CreateUserDefinedFunctionCommand now extends UnaryRunnableCommand with CapturesConfig, wrapping an UnresolvedIdentifier prior to analysis and ResolvedIdentifier post-analysis as its single child node.
  • Removes the duplicate CreateUserDefinedFunction Catalyst logical plan node from v2Commands.scala.
  • Updates CreateSQLFunctionCommand factory and pattern matching usages to construct and handle UnaryRunnableCommand.
  • Added Scaladoc for CreateSQLFunctionCommand.

Why are the changes needed?

Following up on SPARK-48730 (#49126), SQL UDF creation was previously represented across two duplicate logical plan abstractions: a Catalyst plan node (CreateUserDefinedFunction in v2Commands.scala) and an execution command (CreateUserDefinedFunctionCommand).

Extending UnaryRunnableCommand unifies the logical and execution command abstractions into a single UnaryNode in Catalyst, allowing name resolution to delegate cleanly to standard catalog rules (ResolveSessionCatalog).

Does this PR introduce any user-facing change?

No. Internal Catalyst refactoring only.

How was this patch tested?

  • Updated unit test assertions in CreateSQLFunctionParserSuite.
  • Verified Catalyst plan resolution and CreateSQLFunctionCommand execution.

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

No.

…nd from UnaryRunnableCommand

### What changes were proposed in this pull request?
This PR refactors `CreateUserDefinedFunctionCommand` to extend from `UnaryRunnableCommand`, taking `child: LogicalPlan`.

It follows up on apache#49126 (SPARK-48730) by removing the duplicate `CreateUserDefinedFunction` Catalyst logical plan from `v2Commands.scala` and unifying the command structure.

### Why are the changes needed?
To simplify and unify the logical command abstractions for SQL UDFs introduced in apache#49126.

### Does this PR introduce any user-facing change?
No.

### How was this patch tested?
- Updated unit tests in `CreateSQLFunctionParserSuite`.
@zahed1994
zahed1994 force-pushed the SPARK-50698-unary-runnable-udf-command branch from 31b63b5 to 95e3e4b Compare August 28, 2026 18:06
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