@@ -39,9 +39,9 @@ use crate::utils::{
39
39
split_conjunction,
40
40
} ;
41
41
use crate :: {
42
- build_join_schema, expr_vec_fmt, BinaryExpr , CreateMemoryTable , CreateView , Expr ,
43
- ExprSchemable , LogicalPlanBuilder , Operator , TableProviderFilterPushDown ,
44
- TableSource , WindowFunctionDefinition ,
42
+ build_join_schema, expr_vec_fmt, BinaryExpr , CreateMemoryTable , CreateView , Execute ,
43
+ Expr , ExprSchemable , LogicalPlanBuilder , Operator , Prepare ,
44
+ TableProviderFilterPushDown , TableSource , WindowFunctionDefinition ,
45
45
} ;
46
46
47
47
use arrow:: datatypes:: { DataType , Field , Schema , SchemaRef } ;
@@ -262,11 +262,6 @@ pub enum LogicalPlan {
262
262
/// Remove duplicate rows from the input. This is used to
263
263
/// implement SQL `SELECT DISTINCT ...`.
264
264
Distinct ( Distinct ) ,
265
- /// Prepare a statement and find any bind parameters
266
- /// (e.g. `?`). This is used to implement SQL-prepared statements.
267
- Prepare ( Prepare ) ,
268
- /// Execute a prepared statement. This is used to implement SQL 'EXECUTE'.
269
- Execute ( Execute ) ,
270
265
/// Data Manipulation Language (DML): Insert / Update / Delete
271
266
Dml ( DmlStatement ) ,
272
267
/// Data Definition Language (DDL): CREATE / DROP TABLES / VIEWS / SCHEMAS
@@ -314,8 +309,6 @@ impl LogicalPlan {
314
309
LogicalPlan :: Statement ( statement) => statement. schema ( ) ,
315
310
LogicalPlan :: Subquery ( Subquery { subquery, .. } ) => subquery. schema ( ) ,
316
311
LogicalPlan :: SubqueryAlias ( SubqueryAlias { schema, .. } ) => schema,
317
- LogicalPlan :: Prepare ( Prepare { input, .. } ) => input. schema ( ) ,
318
- LogicalPlan :: Execute ( Execute { schema, .. } ) => schema,
319
312
LogicalPlan :: Explain ( explain) => & explain. schema ,
320
313
LogicalPlan :: Analyze ( analyze) => & analyze. schema ,
321
314
LogicalPlan :: Extension ( extension) => extension. node . schema ( ) ,
@@ -448,18 +441,16 @@ impl LogicalPlan {
448
441
LogicalPlan :: Copy ( copy) => vec ! [ & copy. input] ,
449
442
LogicalPlan :: Ddl ( ddl) => ddl. inputs ( ) ,
450
443
LogicalPlan :: Unnest ( Unnest { input, .. } ) => vec ! [ input] ,
451
- LogicalPlan :: Prepare ( Prepare { input, .. } ) => vec ! [ input] ,
452
444
LogicalPlan :: RecursiveQuery ( RecursiveQuery {
453
445
static_term,
454
446
recursive_term,
455
447
..
456
448
} ) => vec ! [ static_term, recursive_term] ,
449
+ LogicalPlan :: Statement ( stmt) => stmt. inputs ( ) ,
457
450
// plans without inputs
458
451
LogicalPlan :: TableScan { .. }
459
- | LogicalPlan :: Statement { .. }
460
452
| LogicalPlan :: EmptyRelation { .. }
461
453
| LogicalPlan :: Values { .. }
462
- | LogicalPlan :: Execute { .. }
463
454
| LogicalPlan :: DescribeTable ( _) => vec ! [ ] ,
464
455
}
465
456
}
@@ -562,8 +553,6 @@ impl LogicalPlan {
562
553
}
563
554
LogicalPlan :: Subquery ( _) => Ok ( None ) ,
564
555
LogicalPlan :: EmptyRelation ( _)
565
- | LogicalPlan :: Prepare ( _)
566
- | LogicalPlan :: Execute ( _)
567
556
| LogicalPlan :: Statement ( _)
568
557
| LogicalPlan :: Values ( _)
569
558
| LogicalPlan :: Explain ( _)
@@ -715,8 +704,6 @@ impl LogicalPlan {
715
704
LogicalPlan :: RecursiveQuery ( _) => Ok ( self ) ,
716
705
LogicalPlan :: Analyze ( _) => Ok ( self ) ,
717
706
LogicalPlan :: Explain ( _) => Ok ( self ) ,
718
- LogicalPlan :: Prepare ( _) => Ok ( self ) ,
719
- LogicalPlan :: Execute ( _) => Ok ( self ) ,
720
707
LogicalPlan :: TableScan ( _) => Ok ( self ) ,
721
708
LogicalPlan :: EmptyRelation ( _) => Ok ( self ) ,
722
709
LogicalPlan :: Statement ( _) => Ok ( self ) ,
@@ -1070,24 +1057,25 @@ impl LogicalPlan {
1070
1057
logical_optimization_succeeded : e. logical_optimization_succeeded ,
1071
1058
} ) )
1072
1059
}
1073
- LogicalPlan :: Prepare ( Prepare {
1074
- name, data_types, ..
1075
- } ) => {
1060
+ LogicalPlan :: Statement ( Statement :: Prepare ( Prepare {
1061
+ name,
1062
+ data_types,
1063
+ ..
1064
+ } ) ) => {
1076
1065
self . assert_no_expressions ( expr) ?;
1077
1066
let input = self . only_input ( inputs) ?;
1078
- Ok ( LogicalPlan :: Prepare ( Prepare {
1067
+ Ok ( LogicalPlan :: Statement ( Statement :: Prepare ( Prepare {
1079
1068
name : name. clone ( ) ,
1080
1069
data_types : data_types. clone ( ) ,
1081
1070
input : Arc :: new ( input) ,
1082
- } ) )
1071
+ } ) ) )
1083
1072
}
1084
- LogicalPlan :: Execute ( Execute { name, schema , .. } ) => {
1073
+ LogicalPlan :: Statement ( Statement :: Execute ( Execute { name, .. } ) ) => {
1085
1074
self . assert_no_inputs ( inputs) ?;
1086
- Ok ( LogicalPlan :: Execute ( Execute {
1075
+ Ok ( LogicalPlan :: Statement ( Statement :: Execute ( Execute {
1087
1076
name : name. clone ( ) ,
1088
- schema : Arc :: clone ( schema) ,
1089
1077
parameters : expr,
1090
- } ) )
1078
+ } ) ) )
1091
1079
}
1092
1080
LogicalPlan :: TableScan ( ts) => {
1093
1081
self . assert_no_inputs ( inputs) ?;
@@ -1184,8 +1172,8 @@ impl LogicalPlan {
1184
1172
/// Replaces placeholder param values (like `$1`, `$2`) in [`LogicalPlan`]
1185
1173
/// with the specified `param_values`.
1186
1174
///
1187
- /// [`LogicalPlan:: Prepare`] are
1188
- /// converted to their inner logical plan for execution.
1175
+ /// [`Prepare`] statements are converted to
1176
+ /// their inner logical plan for execution.
1189
1177
///
1190
1178
/// # Example
1191
1179
/// ```
@@ -1242,13 +1230,17 @@ impl LogicalPlan {
1242
1230
let plan_with_values = self . replace_params_with_values ( & param_values) ?;
1243
1231
1244
1232
// unwrap Prepare
1245
- Ok ( if let LogicalPlan :: Prepare ( prepare_lp) = plan_with_values {
1246
- param_values. verify ( & prepare_lp. data_types ) ?;
1247
- // try and take ownership of the input if is not shared, clone otherwise
1248
- Arc :: unwrap_or_clone ( prepare_lp. input )
1249
- } else {
1250
- plan_with_values
1251
- } )
1233
+ Ok (
1234
+ if let LogicalPlan :: Statement ( Statement :: Prepare ( prepare_lp) ) =
1235
+ plan_with_values
1236
+ {
1237
+ param_values. verify ( & prepare_lp. data_types ) ?;
1238
+ // try and take ownership of the input if is not shared, clone otherwise
1239
+ Arc :: unwrap_or_clone ( prepare_lp. input )
1240
+ } else {
1241
+ plan_with_values
1242
+ } ,
1243
+ )
1252
1244
}
1253
1245
1254
1246
/// Returns the maximum number of rows that this plan can output, if known.
@@ -1346,8 +1338,6 @@ impl LogicalPlan {
1346
1338
| LogicalPlan :: Dml ( _)
1347
1339
| LogicalPlan :: Copy ( _)
1348
1340
| LogicalPlan :: DescribeTable ( _)
1349
- | LogicalPlan :: Prepare ( _)
1350
- | LogicalPlan :: Execute ( _)
1351
1341
| LogicalPlan :: Statement ( _)
1352
1342
| LogicalPlan :: Extension ( _) => None ,
1353
1343
}
@@ -1962,14 +1952,6 @@ impl LogicalPlan {
1962
1952
LogicalPlan :: Analyze { .. } => write ! ( f, "Analyze" ) ,
1963
1953
LogicalPlan :: Union ( _) => write ! ( f, "Union" ) ,
1964
1954
LogicalPlan :: Extension ( e) => e. node . fmt_for_explain ( f) ,
1965
- LogicalPlan :: Prepare ( Prepare {
1966
- name, data_types, ..
1967
- } ) => {
1968
- write ! ( f, "Prepare: {name:?} {data_types:?} " )
1969
- }
1970
- LogicalPlan :: Execute ( Execute { name, parameters, .. } ) => {
1971
- write ! ( f, "Execute: {} params=[{}]" , name, expr_vec_fmt!( parameters) )
1972
- }
1973
1955
LogicalPlan :: DescribeTable ( DescribeTable { .. } ) => {
1974
1956
write ! ( f, "DescribeTable" )
1975
1957
}
@@ -2624,39 +2606,6 @@ impl PartialOrd for Union {
2624
2606
}
2625
2607
}
2626
2608
2627
- /// Prepare a statement but do not execute it. Prepare statements can have 0 or more
2628
- /// `Expr::Placeholder` expressions that are filled in during execution
2629
- #[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Hash ) ]
2630
- pub struct Prepare {
2631
- /// The name of the statement
2632
- pub name : String ,
2633
- /// Data types of the parameters ([`Expr::Placeholder`])
2634
- pub data_types : Vec < DataType > ,
2635
- /// The logical plan of the statements
2636
- pub input : Arc < LogicalPlan > ,
2637
- }
2638
-
2639
- /// Execute a prepared statement.
2640
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2641
- pub struct Execute {
2642
- /// The name of the prepared statement to execute
2643
- pub name : String ,
2644
- /// The execute parameters
2645
- pub parameters : Vec < Expr > ,
2646
- /// Dummy schema
2647
- pub schema : DFSchemaRef ,
2648
- }
2649
-
2650
- // Comparison excludes the `schema` field.
2651
- impl PartialOrd for Execute {
2652
- fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
2653
- match self . name . partial_cmp ( & other. name ) {
2654
- Some ( Ordering :: Equal ) => self . parameters . partial_cmp ( & other. parameters ) ,
2655
- cmp => cmp,
2656
- }
2657
- }
2658
- }
2659
-
2660
2609
/// Describe the schema of table
2661
2610
///
2662
2611
/// # Example output:
0 commit comments