Skip to content

fix: infer LIMIT and OFFSET placeholder parameter types#23260

Open
Probablism wants to merge 1 commit into
apache:mainfrom
Probablism:codex/issue-15978-limit-placeholder-types
Open

fix: infer LIMIT and OFFSET placeholder parameter types#23260
Probablism wants to merge 1 commit into
apache:mainfrom
Probablism:codex/issue-15978-limit-placeholder-types

Conversation

@Probablism

@Probablism Probablism commented Jun 30, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

Bare placeholders used as LIMIT or OFFSET row-count expressions currently remain untyped in LogicalPlan::get_parameter_types(). DataFusion already coerces LIMIT/OFFSET row counts to Int64 during analysis, so the metadata APIs should report the same type for bare row-count placeholders.

What changes are included in this PR?

  • Infer Int64 parameter fields for bare unresolved placeholders used directly as LIMIT or OFFSET expressions.
  • Reuse existing expression placeholder inference before applying the LIMIT/OFFSET fallback, so nested expressions keep their local inference behavior.
  • Preserve existing placeholder conflict detection.
  • Add raw logical-plan and SQL/PREPARE regression tests for LIMIT/OFFSET parameter inference.

Are these changes tested?

Yes:

  • cargo fmt --all -- --check
  • cargo test -p datafusion-expr test_limit_
  • cargo test -p datafusion-sql --test sql_integration test_infer_types_from_limit
  • cargo test -p datafusion-sql --test sql_integration test_prepare_statement_infer_types_from_limit
  • cargo test -p datafusion
  • cargo test -p datafusion-cli
  • cargo test --profile=ci --test sqllogictests
  • ./dev/rust_lint.sh

Are there any user-facing changes?

Yes. LogicalPlan::get_parameter_types() and LogicalPlan::get_parameter_fields() now report Int64 for bare placeholders used directly in LIMIT and OFFSET. There are no breaking API changes.

@github-actions github-actions Bot added sql SQL Planner logical-expr Logical plan and expressions labels Jun 30, 2026
@Probablism Probablism marked this pull request as ready for review June 30, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Placeholder datatype not inferred after LIMIT clause

1 participant