Apache DataFusion SQL Query Engine
minor: refine code (#1951)
xudong.w06bda75cfde0
diff --git a/datafusion/src/execution/context.rs b/datafusion/src/execution/context.rsindex 72bf131eaf..8c43ecd715 100644--- a/datafusion/src/execution/context.rs+++ b/datafusion/src/execution/context.rs@@ -271,9 +271,11 @@ impl ExecutionContext {Ok(Arc::new(DataFrameImpl::new(self.state.clone(), &plan)))}- LogicalPlan::DropTable(DropTable { name, if_exist, .. }) => {+ LogicalPlan::DropTable(DropTable {+ name, if_exists, ..+ }) => {let returned = self.deregister_table(name.as_str())?;- if !if_exist && returned.is_none() {+ if !if_exists && returned.is_none() {Err(DataFusionError::Execution(format!("Memory table {:?} doesn't exist.",namediff --git a/datafusion/src/logical_plan/plan.rs b/datafusion/src/logical_plan/plan.rsindex 64907302ee..60d4845dbb 100644--- a/datafusion/src/logical_plan/plan.rs+++ b/datafusion/src/logical_plan/plan.rs@@ -191,7 +191,7 @@ pub struct DropTable {/// The table namepub name: String,/// If the table exists- pub if_exist: bool,+ pub if_exists: bool,/// Dummy schemapub schema: DFSchemaRef,}@@ -1002,8 +1002,10 @@ impl LogicalPlan {}) => {write!(f, "CreateMemoryTable: {:?}", name)}- LogicalPlan::DropTable(DropTable { name, if_exist, .. }) => {- write!(f, "DropTable: {:?} if not exist:={}", name, if_exist)+ LogicalPlan::DropTable(DropTable {+ name, if_exists, ..+ }) => {+ write!(f, "DropTable: {:?} if not exist:={}", name, if_exists)}LogicalPlan::Explain { .. } => write!(f, "Explain"),LogicalPlan::Analyze { .. } => write!(f, "Analyze"),diff --git a/datafusion/src/sql/planner.rs b/datafusion/src/sql/planner.rsindex c365ac981d..8dd01205b9 100644--- a/datafusion/src/sql/planner.rs+++ b/datafusion/src/sql/planner.rs@@ -50,10 +50,9 @@ use arrow::datatypes::*;use hashbrown::HashMap;use sqlparser::ast::{BinaryOperator, DataType as SQLDataType, DateTimeField, Expr as SQLExpr, FunctionArg,- FunctionArgExpr, HiveDistributionStyle, Ident, Join, JoinConstraint, JoinOperator,- ObjectName, Query, Select, SelectItem, SetExpr, SetOperator, ShowStatementFilter,- TableFactor, TableWithJoins, TrimWhereField, UnaryOperator, Value,- Values as SQLValues,+ FunctionArgExpr, Ident, Join, JoinConstraint, JoinOperator, ObjectName, Query,+ Select, SelectItem, SetExpr, SetOperator, ShowStatementFilter, TableFactor,+ TableWithJoins, TrimWhereField, UnaryOperator, Value, Values as SQLValues,};use sqlparser::ast::{ColumnDef as SQLColumnDef, ColumnOption};use sqlparser::ast::{ObjectType, OrderByExpr, Statement};@@ -150,22 +149,11 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {Statement::CreateTable {query: Some(query),name,- or_replace: false,columns,constraints,- hive_distribution: HiveDistributionStyle::NONE,- hive_formats: _hive_formats,table_properties,with_options,- file_format: None,- location: None,- like: None,- temporary: _temporary,- external: false,- if_not_exists: false,- without_rowid: _without_row_id,- engine: _engine,- default_charset: _default_charset,+ ..} if columns.is_empty()&& constraints.is_empty()&& table_properties.is_empty()@@ -194,7 +182,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {{Ok(LogicalPlan::DropTable(DropTable {name: names.get(0).unwrap().to_string(),- if_exist: *if_exists,+ if_exists: *if_exists,schema: DFSchemaRef::new(DFSchema::empty()),}))}