@@ -46,19 +46,18 @@ use datafusion_expr::{
4646 cast, col, Analyze , CreateCatalog , CreateCatalogSchema ,
4747 CreateExternalTable as PlanCreateExternalTable , CreateFunction , CreateFunctionBody ,
4848 CreateMemoryTable , CreateView , DescribeTable , DmlStatement , DropCatalogSchema ,
49- DropFunction , DropTable , DropView , EmptyRelation , Explain , Expr , ExprSchemable ,
50- Filter , LogicalPlan , LogicalPlanBuilder , OperateFunctionArg , PlanType , Prepare ,
51- SetVariable , Statement as PlanStatement , ToStringifiedPlan , TransactionAccessMode ,
49+ DropFunction , DropTable , DropView , EmptyRelation , Explain , ExprSchemable , Filter ,
50+ LogicalPlan , LogicalPlanBuilder , OperateFunctionArg , PlanType , Prepare , SetVariable ,
51+ Statement as PlanStatement , ToStringifiedPlan , TransactionAccessMode ,
5252 TransactionConclusion , TransactionEnd , TransactionIsolationLevel , TransactionStart ,
5353 Volatility , WriteOp ,
5454} ;
55- use sqlparser:: ast;
55+ use sqlparser:: ast:: { self , AssignmentTarget , CreateTable } ;
5656use sqlparser:: ast:: {
57- Assignment , AssignmentTarget , ColumnDef , CreateTable , CreateTableOptions , Delete ,
58- DescribeAlias , Expr as SQLExpr , FromTable , Ident , Insert , ObjectName , ObjectType ,
59- OneOrManyWithParens , Query , SchemaName , SetExpr , ShowCreateObject ,
60- ShowStatementFilter , Statement , TableConstraint , TableFactor , TableWithJoins ,
61- TransactionMode , UnaryOperator , Value ,
57+ Assignment , ColumnDef , CreateTableOptions , Delete , DescribeAlias , Expr as SQLExpr ,
58+ Expr , FromTable , Ident , Insert , ObjectName , ObjectType , OneOrManyWithParens , Query ,
59+ SchemaName , SetExpr , ShowCreateObject , ShowStatementFilter , Statement ,
60+ TableConstraint , TableFactor , TableWithJoins , TransactionMode , UnaryOperator , Value ,
6261} ;
6362use sqlparser:: parser:: ParserError :: ParserError ;
6463
@@ -955,7 +954,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
955954 order_exprs : Vec < LexOrdering > ,
956955 schema : & DFSchemaRef ,
957956 planner_context : & mut PlannerContext ,
958- ) -> Result < Vec < Vec < Expr > > > {
957+ ) -> Result < Vec < Vec < datafusion_expr :: Expr > > > {
959958 // Ask user to provide a schema if schema is empty.
960959 if !order_exprs. is_empty ( ) && schema. fields ( ) . is_empty ( ) {
961960 return plan_err ! (
@@ -1160,7 +1159,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
11601159 local : bool ,
11611160 hivevar : bool ,
11621161 variables : & OneOrManyWithParens < ObjectName > ,
1163- value : Vec < SQLExpr > ,
1162+ value : Vec < Expr > ,
11641163 ) -> Result < LogicalPlan > {
11651164 if local {
11661165 return not_impl_err ! ( "LOCAL is not supported" ) ;
@@ -1219,7 +1218,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
12191218 fn delete_to_plan (
12201219 & self ,
12211220 table_name : ObjectName ,
1222- predicate_expr : Option < SQLExpr > ,
1221+ predicate_expr : Option < Expr > ,
12231222 ) -> Result < LogicalPlan > {
12241223 // Do a table lookup to verify the table exists
12251224 let table_ref = self . object_name_to_table_reference ( table_name. clone ( ) ) ?;
@@ -1265,7 +1264,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
12651264 table : TableWithJoins ,
12661265 assignments : Vec < Assignment > ,
12671266 from : Option < TableWithJoins > ,
1268- predicate_expr : Option < SQLExpr > ,
1267+ predicate_expr : Option < Expr > ,
12691268 ) -> Result < LogicalPlan > {
12701269 let ( table_name, table_alias) = match & table. relation {
12711270 TableFactor :: Table { name, alias, .. } => ( name. clone ( ) , alias. clone ( ) ) ,
@@ -1298,7 +1297,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
12981297 table_schema. field_with_unqualified_name ( & col_name. value ) ?;
12991298 Ok ( ( col_name. value . clone ( ) , assign. value . clone ( ) ) )
13001299 } )
1301- . collect :: < Result < HashMap < String , SQLExpr > > > ( ) ?;
1300+ . collect :: < Result < HashMap < String , Expr > > > ( ) ?;
13021301
13031302 // Build scan, join with from table if it exists.
13041303 let mut input_tables = vec ! [ table] ;
@@ -1337,7 +1336,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
13371336 & mut planner_context,
13381337 ) ?;
13391338 // Update placeholder's datatype to the type of the target column
1340- if let Expr :: Placeholder ( placeholder) = & mut expr {
1339+ if let datafusion_expr:: Expr :: Placeholder ( placeholder) = & mut expr
1340+ {
13411341 placeholder. data_type = placeholder
13421342 . data_type
13431343 . take ( )
@@ -1349,12 +1349,14 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
13491349 None => {
13501350 // If the target table has an alias, use it to qualify the column name
13511351 if let Some ( alias) = & table_alias {
1352- Expr :: Column ( Column :: new (
1352+ datafusion_expr :: Expr :: Column ( Column :: new (
13531353 Some ( self . normalizer . normalize ( alias. name . clone ( ) ) ) ,
13541354 field. name ( ) ,
13551355 ) )
13561356 } else {
1357- Expr :: Column ( Column :: from ( ( qualifier, field) ) )
1357+ datafusion_expr:: Expr :: Column ( Column :: from ( (
1358+ qualifier, field,
1359+ ) ) )
13581360 }
13591361 }
13601362 } ;
@@ -1429,7 +1431,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
14291431 if let SetExpr :: Values ( ast:: Values { rows, .. } ) = ( * source. body ) . clone ( ) {
14301432 for row in rows. iter ( ) {
14311433 for ( idx, val) in row. iter ( ) . enumerate ( ) {
1432- if let SQLExpr :: Value ( Value :: Placeholder ( name) ) = val {
1434+ if let ast :: Expr :: Value ( Value :: Placeholder ( name) ) = val {
14331435 let name =
14341436 name. replace ( '$' , "" ) . parse :: < usize > ( ) . map_err ( |_| {
14351437 plan_datafusion_err ! ( "Can't parse placeholder: {name}" )
@@ -1462,23 +1464,23 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
14621464 . map ( |( i, value_index) | {
14631465 let target_field = table_schema. field ( i) ;
14641466 let expr = match value_index {
1465- Some ( v) => {
1466- Expr :: Column ( Column :: from ( source. schema ( ) . qualified_field ( v) ) )
1467- . cast_to ( target_field . data_type ( ) , source . schema ( ) ) ?
1468- }
1467+ Some ( v) => datafusion_expr :: Expr :: Column ( Column :: from (
1468+ source. schema ( ) . qualified_field ( v) ,
1469+ ) )
1470+ . cast_to ( target_field . data_type ( ) , source . schema ( ) ) ? ,
14691471 // The value is not specified. Fill in the default value for the column.
14701472 None => table_source
14711473 . get_column_default ( target_field. name ( ) )
14721474 . cloned ( )
14731475 . unwrap_or_else ( || {
14741476 // If there is no default for the column, then the default is NULL
1475- Expr :: Literal ( ScalarValue :: Null )
1477+ datafusion_expr :: Expr :: Literal ( ScalarValue :: Null )
14761478 } )
14771479 . cast_to ( target_field. data_type ( ) , & DFSchema :: empty ( ) ) ?,
14781480 } ;
14791481 Ok ( expr. alias ( target_field. name ( ) ) )
14801482 } )
1481- . collect :: < Result < Vec < Expr > > > ( ) ?;
1483+ . collect :: < Result < Vec < datafusion_expr :: Expr > > > ( ) ?;
14821484 let source = project ( source, exprs) ?;
14831485
14841486 let op = if overwrite {
0 commit comments