Skip to content

fix: Handle EXECUTE without statement name#22204

Merged
Dandandan merged 3 commits into
apache:mainfrom
Dandandan:fix-22197-execute-missing-name
May 16, 2026
Merged

fix: Handle EXECUTE without statement name#22204
Dandandan merged 3 commits 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.

Comment thread datafusion/sql/src/statement.rs
@Dandandan Dandandan enabled auto-merge May 16, 2026 14:14
@Dandandan
Copy link
Copy Markdown
Contributor Author

Thanks @kosiew

@Dandandan Dandandan added this pull request to the merge queue May 16, 2026
Merged via the queue into apache:main with commit 3a49a2f May 16, 2026
38 checks passed
@Dandandan Dandandan deleted the fix-22197-execute-missing-name branch May 16, 2026 14:41
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