@@ -53,7 +53,12 @@ use datafusion_expr::{
53
53
Volatility , WriteOp ,
54
54
} ;
55
55
use sqlparser:: ast;
56
- use sqlparser:: ast:: { Assignment , ColumnDef , CreateTableOptions , Delete , DescribeAlias , Expr as SQLExpr , Expr , FromTable , Ident , Insert , ObjectName , ObjectType , Query , SchemaName , SetExpr , ShowCreateObject , ShowStatementFilter , Statement , TableConstraint , TableFactor , TableWithJoins , TransactionMode , UnaryOperator , Value } ;
56
+ use sqlparser:: ast:: {
57
+ Assignment , ColumnDef , CreateTableOptions , Delete , DescribeAlias , Expr as SQLExpr ,
58
+ Expr , FromTable , Ident , Insert , ObjectName , ObjectType , Query , SchemaName , SetExpr ,
59
+ ShowCreateObject , ShowStatementFilter , Statement , TableConstraint , TableFactor ,
60
+ TableWithJoins , TransactionMode , UnaryOperator , Value ,
61
+ } ;
57
62
use sqlparser:: parser:: ParserError :: ParserError ;
58
63
59
64
fn ident_to_string ( ident : & Ident ) -> String {
@@ -417,18 +422,19 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
417
422
}
418
423
ObjectType :: Schema => {
419
424
let name = match name {
420
- TableReference :: Bare { table } => Ok ( SchemaReference :: Bare { schema : table } ) ,
421
- TableReference :: Partial { schema, table } => Ok ( SchemaReference :: Full { schema : table, catalog : schema } ) ,
425
+ TableReference :: Bare { table } => Ok ( SchemaReference :: Bare { schema : table } ) ,
426
+ TableReference :: Partial { schema, table } => Ok ( SchemaReference :: Full { schema : table, catalog : schema } ) ,
422
427
TableReference :: Full { catalog : _, schema : _, table : _ } => {
423
428
Err ( ParserError ( "Invalid schema specifier (has 3 parts)" . to_string ( ) ) )
424
- } ,
429
+ }
425
430
} ?;
426
431
Ok ( LogicalPlan :: Ddl ( DdlStatement :: DropCatalogSchema ( DropCatalogSchema {
427
432
name,
428
433
if_exists,
429
434
cascade,
430
435
schema : DFSchemaRef :: new ( DFSchema :: empty ( ) ) ,
431
- } ) ) ) } ,
436
+ } ) ) )
437
+ }
432
438
_ => not_impl_err ! (
433
439
"Only `DROP TABLE/VIEW/SCHEMA ...` statement is supported currently"
434
440
) ,
@@ -863,9 +869,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
863
869
864
870
let mut options = HashMap :: new ( ) ;
865
871
for ( key, value) in statement. options {
866
- let value_string = value_to_string ( & value) . ok_or_else ( || {
867
- plan_err ! ( "Unsupported Value in COPY statement {}" , value)
868
- } ) ?;
872
+ let value_string = match value_to_string ( & value) {
873
+ None => {
874
+ return plan_err ! ( "Unsupported Value in COPY statement {}" , value)
875
+ }
876
+ Some ( v) => v,
877
+ } ;
869
878
if !( & key. contains ( '.' ) ) {
870
879
// If config does not belong to any namespace, assume it is
871
880
// a format option and apply the format prefix for backwards
@@ -885,9 +894,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
885
894
} else {
886
895
let e = || {
887
896
DataFusionError :: Configuration (
888
- "Format not explicitly set and unable to get file extension! Use STORED AS to define file format."
889
- . to_string ( ) ,
890
- )
897
+ "Format not explicitly set and unable to get file extension! Use STORED AS to define file format."
898
+ . to_string ( ) ,
899
+ )
891
900
} ;
892
901
// try to infer file format from file extension
893
902
let extension: & str = & Path :: new ( & statement. target )
@@ -1130,9 +1139,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
1130
1139
// parse value string from Expr
1131
1140
let value_string = match & value[ 0 ] {
1132
1141
SQLExpr :: Identifier ( i) => ident_to_string ( i) ,
1133
- SQLExpr :: Value ( v) => value_to_string ( v) . ok_or_else ( || {
1134
- plan_err ! ( "Unsupported Value {}" , value[ 0 ] )
1135
- } ) ?,
1142
+ SQLExpr :: Value ( v) => match value_to_string ( v) {
1143
+ None => {
1144
+ return plan_err ! ( "Unsupported Value {}" , value[ 0 ] ) ;
1145
+ }
1146
+ Some ( v) => v,
1147
+ } ,
1136
1148
// for capture signed number e.g. +8, -8
1137
1149
SQLExpr :: UnaryOp { op, expr } => match op {
1138
1150
UnaryOperator :: Plus => format ! ( "+{expr}" ) ,
0 commit comments