Skip to content

Apache DataFusion SQL Query Engine

Optimize the parameter types of `ParamValues`'s methods (#8613)

Tomoaki Kawadae4674929a1d1
diff --git a/datafusion/common/src/param_value.rs b/datafusion/common/src/param_value.rs
index 1b6195c0d0..004c1371d1 100644
--- a/datafusion/common/src/param_value.rs
+++ b/datafusion/common/src/param_value.rs
@@ -31,7 +31,7 @@ pub enum ParamValues {
impl ParamValues {
/// Verify parameter list length and type
- pub fn verify(&self, expect: &Vec<DataType>) -> Result<()> {
+ pub fn verify(&self, expect: &[DataType]) -> Result<()> {
match self {
ParamValues::List(list) => {
// Verify if the number of params matches the number of values
@@ -67,8 +67,8 @@ impl ParamValues {
pub fn get_placeholders_with_values(
&self,
- id: &String,
- data_type: &Option<DataType>,
+ id: &str,
+ data_type: Option<&DataType>,
) -> Result<ScalarValue> {
match self {
ParamValues::List(list) => {
@@ -88,7 +88,7 @@ impl ParamValues {
))
})?;
// check if the data type of the value matches the data type of the placeholder
- if Some(value.data_type()) != *data_type {
+ if Some(&value.data_type()) != data_type {
return _internal_err!(
"Placeholder value type mismatch: expected {:?}, got {:?}",
data_type,
@@ -107,7 +107,7 @@ impl ParamValues {
))
})?;
// check if the data type of the value matches the data type of the placeholder
- if Some(value.data_type()) != *data_type {
+ if Some(&value.data_type()) != data_type {
return _internal_err!(
"Placeholder value type mismatch: expected {:?}, got {:?}",
data_type,
diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index 1f3711407a..50f4a6b76e 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -1250,8 +1250,8 @@ impl LogicalPlan {
expr.transform(&|expr| {
match &expr {
Expr::Placeholder(Placeholder { id, data_type }) => {
- let value =
- param_values.get_placeholders_with_values(id, data_type)?;
+ let value = param_values
+ .get_placeholders_with_values(id, data_type.as_ref())?;
// Replace the placeholder with the value
Ok(Transformed::Yes(Expr::Literal(value)))
}