diff --git a/src/partition/src/manager.rs b/src/partition/src/manager.rs index 87ce4167a007..c2e036f16a26 100644 --- a/src/partition/src/manager.rs +++ b/src/partition/src/manager.rs @@ -290,7 +290,7 @@ fn create_partitions_from_region_routes( let partition = r .region .partition - .clone() + .as_ref() .context(error::FindRegionRoutesSnafu { region_id: r.region.id, table_id, diff --git a/src/partition/src/partition.rs b/src/partition/src/partition.rs index 9720c2c52bf5..6735ccf6d9f1 100644 --- a/src/partition/src/partition.rs +++ b/src/partition/src/partition.rs @@ -99,23 +99,23 @@ impl PartitionDef { } } -impl TryFrom for PartitionDef { +impl TryFrom<&MetaPartition> for PartitionDef { type Error = Error; - fn try_from(partition: MetaPartition) -> Result { + fn try_from(partition: &MetaPartition) -> Result { let MetaPartition { column_list, value_list, } = partition; let partition_columns = column_list - .into_iter() - .map(|x| String::from_utf8_lossy(&x).to_string()) + .iter() + .map(|x| String::from_utf8_lossy(x).to_string()) .collect::>(); let partition_bounds = value_list - .into_iter() - .map(|x| serde_json::from_str(&String::from_utf8_lossy(&x))) + .iter() + .map(|x| serde_json::from_str(&String::from_utf8_lossy(x))) .collect::, serde_json::Error>>() .context(error::DeserializeJsonSnafu)?; @@ -197,7 +197,7 @@ mod tests { ); // MetaPartition -> PartitionDef - let partition = MetaPartition { + let partition = &MetaPartition { column_list: vec![b"a".to_vec(), b"b".to_vec()], value_list: vec![ b"\"MaxValue\"".to_vec(),