Apache DataFusion SQL Query Engine
Minor: Change no-statement error message to be clearer (#11394)
Junecc7484e0b73f
diff --git a/datafusion/core/src/execution/session_state.rs b/datafusion/core/src/execution/session_state.rsindex c123ebb22e..60745076c2 100644--- a/datafusion/core/src/execution/session_state.rs+++ b/datafusion/core/src/execution/session_state.rs@@ -555,7 +555,7 @@ impl SessionState {}let statement = statements.pop_front().ok_or_else(|| {DataFusionError::NotImplemented(- "The context requires a statement!".to_string(),+ "No SQL statements were provided in the query string".to_string(),)})?;Ok(statement)diff --git a/datafusion/core/tests/sql/sql_api.rs b/datafusion/core/tests/sql/sql_api.rsindex 4a6424fc24..e7c40d2c8a 100644--- a/datafusion/core/tests/sql/sql_api.rs+++ b/datafusion/core/tests/sql/sql_api.rs@@ -113,6 +113,40 @@ async fn unsupported_statement_returns_error() {ctx.sql_with_options(sql, options).await.unwrap();}+#[tokio::test]+async fn empty_statement_returns_error() {+ let ctx = SessionContext::new();+ ctx.sql("CREATE TABLE test (x int)").await.unwrap();++ let state = ctx.state();++ // Give it an empty string which contains no statements+ 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"+ );+}++#[tokio::test]+async fn multiple_statements_returns_error() {+ let ctx = SessionContext::new();+ ctx.sql("CREATE TABLE test (x int)").await.unwrap();++ let state = ctx.state();++ // Give it a string that contains multiple statements+ let plan_res = state+ .create_logical_plan(+ "INSERT INTO test (x) VALUES (1); INSERT INTO test (x) VALUES (2)",+ )+ .await;+ assert_eq!(+ plan_res.unwrap_err().strip_backtrace(),+ "This feature is not implemented: The context currently only supports a single SQL statement"+ );+}+#[tokio::test]async fn ddl_can_not_be_planned_by_session_state() {let ctx = SessionContext::new();