Skip to content

fix: Handle EXECUTE without statement name#22204

Open
Dandandan wants to merge 1 commit into
apache:mainfrom
Dandandan:fix-22197-execute-missing-name
Open

fix: Handle EXECUTE without statement name#22204
Dandandan wants to merge 1 commit into
apache:mainfrom
Dandandan:fix-22197-execute-missing-name

Conversation

@Dandandan
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

EXEC() and EXECUTE() can parse as Statement::Execute without a statement name. The planner previously unwrapped that optional name and panicked on user-supplied SQL.

What changes are included in this PR?

  • Return a planning error when EXECUTE has no statement name.
  • Add sqllogictest coverage for the malformed EXEC / EXECUTE forms from the issue.

Are these changes tested?

  • cargo test -p datafusion-sqllogictest --test sqllogictests -- prepare
  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings

Are there any user-facing changes?

Malformed EXEC / EXECUTE statements without a name now return a planning error instead of panicking.

@github-actions github-actions Bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels May 15, 2026
@Dandandan Dandandan changed the title Handle EXECUTE without statement name fix: Handle EXECUTE without statement name May 15, 2026
Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dandandan

Looks 👍 to me
I have one small suggestion that could make the invariant handling a bit more consistent.

);
}
let empty_schema = DFSchema::empty();
let parameters = parameters
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small suggestion: consider validating name before planning parameters. Right now, nameless forms with non-literal arguments can still fail during parameter expression planning before reaching the missing-name check. Moving the ok_or_else earlier would make all nameless EXECUTE syntax return the same actionable error and would encode the invariant a bit earlier in the flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic on EXEC() / EXECUTE() with no name: Option::unwrap() on None in statement.rs

2 participants