Skip to content

Commit

Permalink
refactor: change error type for "no statement"
Browse files Browse the repository at this point in the history
Amends apache#11394 (sorry, I should have reviewed that).

While reporting "not implemented" for "multiple statements" seems
reasonable, I think the user should get a plan error (which roughly
translates to "invalid argument") if they don't provide any statement. I
don't see any reasonable way to support "no statement" ever, hence "not
implemented" seems like a wrong promise.
  • Loading branch information
crepererum committed Jul 11, 2024
1 parent 7a23ea9 commit 1f2ced0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion datafusion/core/src/execution/session_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ impl SessionState {
);
}
let statement = statements.pop_front().ok_or_else(|| {
DataFusionError::NotImplemented(
DataFusionError::Plan(
"No SQL statements were provided in the query string".to_string(),
)
})?;
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/sql/sql_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async fn empty_statement_returns_error() {
let plan_res = state.create_logical_plan("").await;
assert_eq!(
plan_res.unwrap_err().strip_backtrace(),
"This feature is not implemented: No SQL statements were provided in the query string"
"Error during planning: No SQL statements were provided in the query string"
);
}

Expand Down

0 comments on commit 1f2ced0

Please sign in to comment.