Skip to content

Spark 4.1: bind parameters in IcebergSparkSqlExtensionsParser#16626

Open
j1wonpark wants to merge 1 commit into
apache:mainfrom
j1wonpark:spark-4.1-bind-parameters
Open

Spark 4.1: bind parameters in IcebergSparkSqlExtensionsParser#16626
j1wonpark wants to merge 1 commit into
apache:mainfrom
j1wonpark:spark-4.1-bind-parameters

Conversation

@j1wonpark
Copy link
Copy Markdown

Closes #16625.

Root cause

Spark 4.1 routes parameterized queries through ParserInterface.parsePlanWithParameters(sqlText, parameterContext) (SPARK-53573). The trait's default implementation ignores the ParameterContext and falls back to parsePlan. IcebergSparkSqlExtensionsParser overrides parsePlan but not parsePlanWithParameters, so with the extensions installed the context is dropped and parameter markers are never bound. Only 4.1 is affected — the method and ParameterContext are new in 4.1; 3.5 and 4.0 bind parameters post-parse.

Fix

Override parsePlanWithParameters to mirror parsePlan: Iceberg commands keep the existing path, everything else delegates to the wrapped Spark parser with the ParameterContext intact.

Testing

Added regression tests in TestExtendedParser (all fail without the fix, pass with it):

  • testParsePlanWithParametersDelegatesForNonIcebergSql — non-Iceberg SQL delegates with the context preserved.
  • testParsePlanWithParametersBindsPositionalParameterSELECT ? AS id binds end-to-end.
  • testParsePlanWithParametersBindsNamedParameterSELECT :id AS id binds end-to-end.

spotlessCheck, scalastyle*Check, and checkstyle* all pass.

Spark 4.1 routes parameterized queries through
ParserInterface.parsePlanWithParameters, whose default implementation
drops the parameter context and falls back to parsePlan. The Iceberg
extensions parser delegates non-Iceberg SQL to the Spark parser but did
not override parsePlanWithParameters, so positional and named parameters
were left unbound (UNBOUND_SQL_PARAMETER) for any SQL routed through the
Iceberg session extensions on Spark Connect.

Override parsePlanWithParameters to delegate with the parameter context
intact, mirroring parsePlan.

Signed-off-by: Jiwon Park <jpark92@outlook.kr>
@github-actions github-actions Bot added the spark label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spark: parameterized queries fail with UNBOUND_SQL_PARAMETER when Iceberg SQL extensions are enabled

1 participant