From 4a2f7dbee16c028d8091bdb0f388304a896d9997 Mon Sep 17 00:00:00 2001 From: Dennis Zhuang Date: Thu, 30 May 2024 14:09:11 -0700 Subject: [PATCH] chore: change ViewInfo::new signature --- src/catalog/src/table_source.rs | 2 +- src/common/meta/src/cache/table/view_info.rs | 2 +- src/common/meta/src/ddl/create_view.rs | 2 +- src/common/meta/src/ddl/tests/create_view.rs | 4 ++-- src/common/meta/src/key.rs | 10 ++++++---- src/common/meta/src/key/view_info.rs | 4 ++-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/catalog/src/table_source.rs b/src/catalog/src/table_source.rs index 27ff3dbf18ef..7399dca550da 100644 --- a/src/catalog/src/table_source.rs +++ b/src/catalog/src/table_source.rs @@ -277,7 +277,7 @@ mod tests { let logical_plan = vec![1, 2, 3]; // Create view metadata table_metadata_manager - .create_view_metadata(view_info.clone().into(), &logical_plan, HashSet::new()) + .create_view_metadata(view_info.clone().into(), logical_plan, HashSet::new()) .await .unwrap(); diff --git a/src/common/meta/src/cache/table/view_info.rs b/src/common/meta/src/cache/table/view_info.rs index da53b522ab31..cd9d29b2ca4d 100644 --- a/src/common/meta/src/cache/table/view_info.rs +++ b/src/common/meta/src/cache/table/view_info.rs @@ -116,7 +116,7 @@ mod tests { table_metadata_manager .create_view_metadata( task.view_info.clone(), - &task.create_view.logical_plan, + task.create_view.logical_plan.clone(), table_names, ) .await diff --git a/src/common/meta/src/ddl/create_view.rs b/src/common/meta/src/ddl/create_view.rs index 7dbbabf2c73f..fa7a115d4d8a 100644 --- a/src/common/meta/src/ddl/create_view.rs +++ b/src/common/meta/src/ddl/create_view.rs @@ -208,7 +208,7 @@ impl CreateViewProcedure { manager .create_view_metadata( raw_view_info, - self.data.task.raw_logical_plan(), + self.data.task.raw_logical_plan().clone(), self.data.task.table_names(), ) .await?; diff --git a/src/common/meta/src/ddl/tests/create_view.rs b/src/common/meta/src/ddl/tests/create_view.rs index 9c26ca1346e8..4dc589dbb883 100644 --- a/src/common/meta/src/ddl/tests/create_view.rs +++ b/src/common/meta/src/ddl/tests/create_view.rs @@ -102,7 +102,7 @@ async fn test_on_prepare_view_exists_err() { .table_metadata_manager .create_view_metadata( task.view_info.clone(), - &task.create_view.logical_plan, + task.create_view.logical_plan.clone(), test_table_names(), ) .await @@ -126,7 +126,7 @@ async fn test_on_prepare_with_create_if_view_exists() { .table_metadata_manager .create_view_metadata( task.view_info.clone(), - &task.create_view.logical_plan, + task.create_view.logical_plan.clone(), test_table_names(), ) .await diff --git a/src/common/meta/src/key.rs b/src/common/meta/src/key.rs index f252e679211f..a8ef1e7eb781 100644 --- a/src/common/meta/src/key.rs +++ b/src/common/meta/src/key.rs @@ -490,7 +490,7 @@ impl TableMetadataManager { pub async fn create_view_metadata( &self, view_info: RawTableInfo, - raw_logical_plan: &Vec, + raw_logical_plan: Vec, table_names: HashSet, ) -> Result<()> { let view_id = view_info.ident.table_id; @@ -2009,7 +2009,7 @@ mod tests { // Create metadata table_metadata_manager - .create_view_metadata(view_info.clone(), &logical_plan, table_names.clone()) + .create_view_metadata(view_info.clone(), logical_plan.clone(), table_names.clone()) .await .unwrap(); @@ -2051,8 +2051,10 @@ mod tests { set }; - let current_view_info_value = - DeserializedValueWithBytes::from_inner(ViewInfoValue::new(&logical_plan, table_names)); + let current_view_info_value = DeserializedValueWithBytes::from_inner(ViewInfoValue::new( + logical_plan.clone(), + table_names, + )); // should be ok. table_metadata_manager .update_view_info( diff --git a/src/common/meta/src/key/view_info.rs b/src/common/meta/src/key/view_info.rs index 9e5180aa3a1f..762acf9aa3d3 100644 --- a/src/common/meta/src/key/view_info.rs +++ b/src/common/meta/src/key/view_info.rs @@ -90,9 +90,9 @@ pub struct ViewInfoValue { } impl ViewInfoValue { - pub fn new(view_info: &RawViewLogicalPlan, table_names: HashSet) -> Self { + pub fn new(view_info: RawViewLogicalPlan, table_names: HashSet) -> Self { Self { - view_info: view_info.clone(), + view_info, table_names, version: 0, }