Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgao committed Nov 4, 2024
1 parent 35a682f commit c81c1b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,14 +694,21 @@ impl SessionContext {
data_types,
}) => {
// The number of parameters must match the specified data types length.
let param_names = input.get_parameter_names()?;
if param_names.len() != data_types.len() {
return plan_err!(
"Prepare specifies {} data types but query has {} parameters",
data_types.len(),
param_names.len()
);
if !data_types.is_empty() {
let param_names = input.get_parameter_names()?;
if param_names.len() != data_types.len() {
return plan_err!(
"Prepare specifies {} data types but query has {} parameters",
data_types.len(),
param_names.len()
);
}
}
// Store the unoptimized plan into the session state. Although storing the
// optimized plan or the physical plan would be more efficient, doing so is
// not currently feasible. This is because `now()` would be optimized to a
// constant value, causing each EXECUTE to yield the same result, which is
// incorrect behavior.
self.state.write().store_prepared(name, data_types, input)?;
self.return_empty_dataframe()
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/execution/session_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ impl SessionState {
Ok(udtf.map(|x| x.function().clone()))
}

/// Store the logical plan and parameter types of a prepared statement.
/// Store the logical plan and the parameter types of a prepared statement.
pub(crate) fn store_prepared(
&mut self,
name: String,
Expand Down

0 comments on commit c81c1b4

Please sign in to comment.