Skip to content

Commit c81c1b4

Browse files
committed
Update doc
1 parent 35a682f commit c81c1b4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

datafusion/core/src/execution/context/mod.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -694,14 +694,21 @@ impl SessionContext {
694694
data_types,
695695
}) => {
696696
// The number of parameters must match the specified data types length.
697-
let param_names = input.get_parameter_names()?;
698-
if param_names.len() != data_types.len() {
699-
return plan_err!(
700-
"Prepare specifies {} data types but query has {} parameters",
701-
data_types.len(),
702-
param_names.len()
703-
);
697+
if !data_types.is_empty() {
698+
let param_names = input.get_parameter_names()?;
699+
if param_names.len() != data_types.len() {
700+
return plan_err!(
701+
"Prepare specifies {} data types but query has {} parameters",
702+
data_types.len(),
703+
param_names.len()
704+
);
705+
}
704706
}
707+
// Store the unoptimized plan into the session state. Although storing the
708+
// optimized plan or the physical plan would be more efficient, doing so is
709+
// not currently feasible. This is because `now()` would be optimized to a
710+
// constant value, causing each EXECUTE to yield the same result, which is
711+
// incorrect behavior.
705712
self.state.write().store_prepared(name, data_types, input)?;
706713
self.return_empty_dataframe()
707714
}

datafusion/core/src/execution/session_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ impl SessionState {
911911
Ok(udtf.map(|x| x.function().clone()))
912912
}
913913

914-
/// Store the logical plan and parameter types of a prepared statement.
914+
/// Store the logical plan and the parameter types of a prepared statement.
915915
pub(crate) fn store_prepared(
916916
&mut self,
917917
name: String,

0 commit comments

Comments
 (0)