Skip to content

[SPARK-52719][SQL] Support using scalar UDFs in TVF arguments#55950

Open
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-52719-udf-in-tvf
Open

[SPARK-52719][SQL] Support using scalar UDFs in TVF arguments#55950
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-52719-udf-in-tvf

Conversation

@yadavay-amzn
Copy link
Copy Markdown
Contributor

@yadavay-amzn yadavay-amzn commented May 18, 2026

What changes were proposed in this pull request?

Narrows the check in ResolveSQLFunctions that rejects SQL functions in TVF arguments to only reject table-valued functions, allowing scalar UDFs to pass through for normal resolution.

Why are the changes needed?

SELECT * FROM tvf(scalar_udf(true)) incorrectly throws AnalysisException: Using SQL function ... in SQLTableFunction is not supported. Scalar UDFs return scalar values and should be valid TVF arguments.

Does this PR introduce any user-facing change?

Yes, scalar SQL UDFs can now be used as arguments to table-valued functions.

How was this patch tested?

Added test in SQLFunctionSuite that creates a scalar UDF and a TVF, then verifies SELECT * FROM table_func(scalar_udf(1)) returns the expected result. Test fails without the fix (AnalysisException), passes with it.

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

No

Narrows the check that rejects SQL functions in TVF arguments to
only reject table-valued functions, allowing scalar UDFs to be
used as TVF arguments.

Closes #SPARK-52719
@yadavay-amzn
Copy link
Copy Markdown
Contributor Author

yadavay-amzn commented May 20, 2026

@allisonwang-db Could you please take a look at this one-liner when you get a chance?
This fixes the AnalysisException you reported in SPARK-52719 (scalar UDFs in TVF arguments).

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