Apache DataFusion SQL Query Engine
port errors.rs test to context.rs (#6340)
masanobbb2c1161abde17
diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rsindex d76e26e1b7..5d5195e2c4 100644--- a/datafusion/core/src/execution/context.rs+++ b/datafusion/core/src/execution/context.rs@@ -2576,6 +2576,43 @@ mod tests {Ok(())}+ #[tokio::test]+ async fn unsupported_sql_returns_error() -> Result<()> {+ let ctx = SessionContext::new();+ ctx.register_table("test", test::table_with_sequence(1, 1).unwrap())+ .unwrap();+ let state = ctx.state();++ // create view+ let sql = "create view test_view as select * from test";+ let plan = state.create_logical_plan(sql).await;+ let physical_plan = state.create_physical_plan(&plan.unwrap()).await;+ assert!(physical_plan.is_err());+ assert_eq!(+ format!("{}", physical_plan.unwrap_err()),+ "This feature is not implemented: Unsupported logical plan: CreateView"+ );+ // // drop view+ let sql = "drop view test_view";+ let plan = state.create_logical_plan(sql).await;+ let physical_plan = state.create_physical_plan(&plan.unwrap()).await;+ assert!(physical_plan.is_err());+ assert_eq!(+ format!("{}", physical_plan.unwrap_err()),+ "This feature is not implemented: Unsupported logical plan: DropView"+ );+ // // drop table+ let sql = "drop table test";+ let plan = state.create_logical_plan(sql).await;+ let physical_plan = state.create_physical_plan(&plan.unwrap()).await;+ assert!(physical_plan.is_err());+ assert_eq!(+ format!("{}", physical_plan.unwrap_err()),+ "This feature is not implemented: Unsupported logical plan: DropTable"+ );+ Ok(())+ }+struct MyPhysicalPlanner {}#[async_trait]diff --git a/datafusion/core/tests/sql/errors.rs b/datafusion/core/tests/sql/errors.rsdeleted file mode 100644index 343551f1f0..0000000000--- a/datafusion/core/tests/sql/errors.rs+++ /dev/null@@ -1,54 +0,0 @@-// Licensed to the Apache Software Foundation (ASF) under one-// or more contributor license agreements. See the NOTICE file-// distributed with this work for additional information-// regarding copyright ownership. The ASF licenses this file-// to you under the Apache License, Version 2.0 (the-// "License"); you may not use this file except in compliance-// with the License. You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing,-// software distributed under the License is distributed on an-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-// KIND, either express or implied. See the License for the-// specific language governing permissions and limitations-// under the License.--use super::*;--#[tokio::test]-async fn unsupported_sql_returns_error() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_csv(&ctx).await?;- let state = ctx.state();-- // create view- let sql = "create view test_view as select * from aggregate_test_100";- let plan = state.create_logical_plan(sql).await;- let physical_plan = state.create_physical_plan(&plan.unwrap()).await;- assert!(physical_plan.is_err());- assert_eq!(- format!("{}", physical_plan.unwrap_err()),- "This feature is not implemented: Unsupported logical plan: CreateView"- );- // // drop view- let sql = "drop view test_view";- let plan = state.create_logical_plan(sql).await;- let physical_plan = state.create_physical_plan(&plan.unwrap()).await;- assert!(physical_plan.is_err());- assert_eq!(- format!("{}", physical_plan.unwrap_err()),- "This feature is not implemented: Unsupported logical plan: DropView"- );- // // drop table- let sql = "drop table aggregate_test_100";- let plan = state.create_logical_plan(sql).await;- let physical_plan = state.create_physical_plan(&plan.unwrap()).await;- assert!(physical_plan.is_err());- assert_eq!(- format!("{}", physical_plan.unwrap_err()),- "This feature is not implemented: Unsupported logical plan: DropTable"- );- Ok(())-}diff --git a/datafusion/core/tests/sql/mod.rs b/datafusion/core/tests/sql/mod.rsindex 7041cf7a1f..8dcae60570 100644--- a/datafusion/core/tests/sql/mod.rs+++ b/datafusion/core/tests/sql/mod.rs@@ -82,7 +82,6 @@ pub mod aggregates;#[cfg(feature = "avro")]pub mod avro;pub mod create_drop;-pub mod errors;pub mod explain_analyze;pub mod expr;pub mod functions;