From 1a22eda84066af7bfe4f810b018076d106fabdec Mon Sep 17 00:00:00 2001 From: Noel Kwan Date: Wed, 3 Jul 2024 00:06:31 +0800 Subject: [PATCH] fix ut --- src/frontend/src/catalog/schema_catalog.rs | 4 ++-- src/frontend/src/handler/alter_rename.rs | 3 +-- src/frontend/src/test_utils.rs | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/catalog/schema_catalog.rs b/src/frontend/src/catalog/schema_catalog.rs index fb78506a8c145..444abbec344ad 100644 --- a/src/frontend/src/catalog/schema_catalog.rs +++ b/src/frontend/src/catalog/schema_catalog.rs @@ -612,7 +612,7 @@ impl SchemaCatalog { pub fn get_created_table_by_name(&self, table_name: &str) -> Option<&Arc> { self.table_by_name .get(table_name) - .filter(|&table| table.stream_job_status != StreamJobStatus::Creating) + .filter(|&table| table.stream_job_status == StreamJobStatus::Created) } pub fn get_table_by_id(&self, table_id: &TableId) -> Option<&Arc> { @@ -622,7 +622,7 @@ impl SchemaCatalog { pub fn get_created_table_by_id(&self, table_id: &TableId) -> Option<&Arc> { self.table_by_id .get(table_id) - .filter(|&table| table.stream_job_status != StreamJobStatus::Creating) + .filter(|&table| table.stream_job_status == StreamJobStatus::Created) } pub fn get_view_by_name(&self, view_name: &str) -> Option<&Arc> { diff --git a/src/frontend/src/handler/alter_rename.rs b/src/frontend/src/handler/alter_rename.rs index 347b4e679f8e0..772fad9c35a7b 100644 --- a/src/frontend/src/handler/alter_rename.rs +++ b/src/frontend/src/handler/alter_rename.rs @@ -332,7 +332,6 @@ pub async fn handle_rename_database( #[cfg(test)] mod tests { - use risingwave_common::catalog::{DEFAULT_DATABASE_NAME, DEFAULT_SCHEMA_NAME}; use crate::catalog::root_catalog::SchemaPath; @@ -350,7 +349,7 @@ mod tests { let table_id = { let catalog_reader = session.env().catalog_reader().read_guard(); catalog_reader - .get_created_table_by_name(DEFAULT_DATABASE_NAME, schema_path, "t") + .get_table_by_name(DEFAULT_DATABASE_NAME, schema_path, "t") .unwrap() .0 .id diff --git a/src/frontend/src/test_utils.rs b/src/frontend/src/test_utils.rs index 7969bb18c4746..15ace31494187 100644 --- a/src/frontend/src/test_utils.rs +++ b/src/frontend/src/test_utils.rs @@ -35,8 +35,8 @@ use risingwave_hummock_sdk::version::{HummockVersion, HummockVersionDelta}; use risingwave_pb::backup_service::MetaSnapshotMetadata; use risingwave_pb::catalog::table::OptionalAssociatedSourceId; use risingwave_pb::catalog::{ - PbComment, PbDatabase, PbFunction, PbIndex, PbSchema, PbSink, PbSource, PbSubscription, - PbTable, PbView, Table, + PbComment, PbDatabase, PbFunction, PbIndex, PbSchema, PbSink, PbSource, PbStreamJobStatus, + PbSubscription, PbTable, PbView, Table, }; use risingwave_pb::common::WorkerNode; use risingwave_pb::ddl_service::alter_owner_request::Object; @@ -274,6 +274,7 @@ impl CatalogWriter for MockCatalogWriter { _graph: StreamFragmentGraph, ) -> Result<()> { table.id = self.gen_id(); + table.stream_job_status = PbStreamJobStatus::Created as _; self.catalog.write().create_table(&table); self.add_table_or_source_id(table.id, table.schema_id, table.database_id); Ok(())