MCPcopy Create free account
hub / github.com/apache/datafusion / with_param_values

Method with_param_values

datafusion/expr/src/logical_plan/plan.rs:1285–1304  ·  view source on GitHub ↗

Replaces placeholder param values (like `$1`, `$2`) in [`LogicalPlan`] with the specified `param_values`. [`Prepare`] statements are converted to their inner logical plan for execution. # Example ``` # use arrow::datatypes::{Field, Schema, DataType}; use datafusion_common::ScalarValue; # use datafusion_expr::{lit, col, LogicalPlanBuilder, logical_plan::table_scan, placeholder}; # let schema = Sc

(
        self,
        param_values: impl Into<ParamValues>,
    )

Source from the content-addressed store, hash-verified

1283 /// );
1284 /// ```
1285 pub fn with_param_values(
1286 self,
1287 param_values: impl Into<ParamValues>,
1288 ) -> Result<LogicalPlan> {
1289 let param_values = param_values.into();
1290 let plan_with_values = self.replace_params_with_values(&param_values)?;
1291
1292 // unwrap Prepare
1293 Ok(
1294 if let LogicalPlan::Statement(Statement::Prepare(prepare_lp)) =
1295 plan_with_values
1296 {
1297 param_values.verify_fields(&prepare_lp.fields)?;
1298 // try and take ownership of the input if is not shared, clone otherwise
1299 Arc::unwrap_or_clone(prepare_lp.input)
1300 } else {
1301 plan_with_values
1302 },
1303 )
1304 }
1305
1306 /// Returns the maximum number of rows that this plan can output, if known.
1307 ///

Calls 3

verify_fieldsMethod · 0.80
intoMethod · 0.45