Skip to content

fix: return Plan error instead of Internal error when no functions are registered - #27831

Open
rctruta wants to merge 1 commit into
apache:mainfrom
rctruta:fix/no-functions-registered-plan-err
Open

rctruta wants to merge 1 commit into
apache:mainfrom
rctruta:fix/no-functions-registered-plan-err

Conversation

@rctruta

@rctruta rctruta commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Follow-on to #27674 (per review feedback from @2010YOUY01 and @alamb)

Rationale for this change

Running a ContextProvider with no registered functions is a valid configuration, so failing to resolve a SQL function in that context should return a DataFusionError::Plan (plan_err!) rather than DataFusionError::Internal (internal_err!).

What changes are included in this PR?

  • datafusion/sql/src/expr/function.rs: Return plan_err!("No functions registered with this context.") instead of internal_err!(...) when no functions are registered in the context.
  • datafusion/sql/tests/sql_integration.rs: Update the assertion in test_no_functions_registered from "Internal error: ..." to "Error during planning: ...".

What is the testing strategy for this PR?

Yes:

  • cargo test -p datafusion-sql
  • cargo clippy -p datafusion-sql --all-targets --no-deps -- -D warnings
  • cargo fmt -p datafusion-sql -- --check

Are there any user-facing changes?

Calling a SQL function against a context with no registered functions now returns DataFusionError::Plan ("Error during planning: No functions registered with this context.") instead of DataFusionError::Internal.

@github-actions github-actions Bot added the sql SQL Planner label Nov 29, 2026

@Areesha-Rizwan412 Areesha-Rizwan412 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified this is the follow-on @alamb asked for in #27674 - @2010YOUY01 suggested the exact plan_err! there, and this PR applies it.

Checked at head: plan_err! is already imported and used throughout this file, and the sibling invalid-function path right below (plan_err!("Invalid function '{name}'.")) already returns a plan error, so the no-functions case is now consistent with it. A context with no registered functions is a valid setup, not an internal failure, so DataFusionError::Plan is the right variant here. The updated test assertion matches the Plan display prefix (Error during planning: ) in datafusion/common/src/error.rs.

CI is green. LGTM.

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

Labels

sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants