From 83efb63a5d86deff6934544986b3762eb5c06ec8 Mon Sep 17 00:00:00 2001 From: masanobbb <10200143+masanobbb@users.noreply.github.com> Date: Thu, 11 May 2023 22:46:21 +0900 Subject: [PATCH] port errors.rs test to context.rs --- datafusion/core/src/execution/context.rs | 37 ++++++++++++++++ datafusion/core/tests/sql/errors.rs | 54 ------------------------ datafusion/core/tests/sql/mod.rs | 1 - 3 files changed, 37 insertions(+), 55 deletions(-) delete mode 100644 datafusion/core/tests/sql/errors.rs diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs index d76e26e1b77c..5d5195e2c461 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.rs deleted file mode 100644 index 343551f1f0d0..000000000000 --- 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.rs index cbccf333b304..e25ffaf5ee83 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;