From ab72703f2e2b787400f1f8d21ca69eed2c8a233d Mon Sep 17 00:00:00 2001 From: QP Hou Date: Mon, 15 Nov 2021 04:04:38 -0800 Subject: [PATCH] improve error message for invalid create table statement (#1294) * improve error message for invalid create table statement * handle different create table cases using match --- datafusion/src/sql/planner.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/datafusion/src/sql/planner.rs b/datafusion/src/sql/planner.rs index 3e1e76d7fdfd..77eee2946cbd 100644 --- a/datafusion/src/sql/planner.rs +++ b/datafusion/src/sql/planner.rs @@ -162,6 +162,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { input: Arc::new(plan), }) } + Statement::CreateTable { .. } => Err(DataFusionError::NotImplemented( + "Only `CREATE TABLE table_name AS SELECT ...` statement is supported" + .to_string(), + )), Statement::Drop { object_type: ObjectType::Table, @@ -185,9 +189,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { table_name, filter, } => self.show_columns_to_plan(*extended, *full, table_name, filter.as_ref()), - _ => Err(DataFusionError::NotImplemented( - "Only SELECT statements are implemented".to_string(), - )), + _ => Err(DataFusionError::NotImplemented(format!( + "Unsupported SQL statement: {:?}", + sql + ))), } }