[spark] Support SQL-defined UDFs for Spark 4#8299
Open
Zouxxyy wants to merge 4 commits into
Open
Conversation
…on Paimon catalog for Spark 4 Intercept `CreateUserDefinedFunction` at the parser stage and persist the SQL function in the Paimon catalog as a SQLFunctionDefinition; at query time rebuild a Spark SQLFunctionExpression so Spark's own ResolveSQLFunctions / EliminateSQLFunctionNode inline the body. No Spark changes required. Scalar functions with an expression body or a single-column query body are supported; table functions are rejected for now. All Spark-4-only code (CreateUserDefinedFunction / SQLFunction / SQLFunctionExpression) is confined to paimon-spark4-common behind SparkShim; the spark3 shim is a no-op so paimon-spark-common still compiles against Spark 3. - new (spark4-common): SQLFunctionConverter, RewritePaimonSQLFunctionCommands, CreatePaimonSQLFunctionCommand - common: extract PaimonFunctionLookup; recognize SQLFunctionDefinition in the function-reference rewrite; route SQL functions through SparkShim in PaimonV1FunctionRegistry; append shim parser rules - tests: PaimonSQLFunctionTest (expression body, query body, OR REPLACE / IF NOT EXISTS, qualified names, DROP, table-function rejection) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Cool! |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Looks good to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Support SQL-defined scalar UDFs (
CREATE FUNCTION ... RETURN) on Paimon catalog for Spark 4.Intercept
CreateUserDefinedFunctionat the parser stage and persist the SQLfunction in the Paimon catalog as a
SQLFunctionDefinition; at query time rebuild aSpark
SQLFunctionExpressionso Spark's ownResolveSQLFunctions/EliminateSQLFunctionNodeinline the body. No Spark changes required.
Scalar functions with an expression body or a single-column query body are
supported; table functions are rejected for now. All Spark-4-only code
(
CreateUserDefinedFunction/SQLFunction/SQLFunctionExpression) is confined topaimon-spark4-commonbehindSparkShim; the spark3 shim is a no-op sopaimon-spark-commonstill compiles against Spark 3.Key changes:
SQLFunctionConverter,RewritePaimonSQLFunctionCommands,CreatePaimonSQLFunctionCommandPaimonFunctionLookup; recognizeSQLFunctionDefinitionin the function-reference rewrite; route SQL functions throughSparkShiminPaimonV1FunctionRegistry; append shim parser rulesV1FunctionConverter→FileFunctionConverter+FunctionIdentifierConverter(shared)Tests
PaimonSQLFunctionTest(expression body, query body, OR REPLACE / IF NOT EXISTS, qualified names, DROP, table-function rejection) in spark-4.0 and spark-4.1