diff --git a/src/common/meta/src/ddl/utils.rs b/src/common/meta/src/ddl/utils.rs index fd1737a3e6b7..b1608d40e369 100644 --- a/src/common/meta/src/ddl/utils.rs +++ b/src/common/meta/src/ddl/utils.rs @@ -18,6 +18,7 @@ use common_procedure::error::Error as ProcedureError; use snafu::{ensure, OptionExt, ResultExt}; use store_api::metric_engine_consts::LOGICAL_TABLE_METADATA_KEY; use table::metadata::TableId; +use table::table_reference::TableReference; use crate::ddl::DetectingRegion; use crate::error::{Error, OperateDatanodeSnafu, Result, TableNotFoundSnafu, UnsupportedSnafu}; @@ -109,8 +110,8 @@ pub async fn check_and_get_physical_table_id( .table_name_manager() .get(physical_table_name) .await? - .context(TableNotFoundSnafu { - table_name: physical_table_name.to_string(), + .with_context(|| TableNotFoundSnafu { + table_name: TableReference::from(physical_table_name).to_string(), }) .map(|table| table.table_id()) } @@ -123,8 +124,8 @@ pub async fn get_physical_table_id( .table_name_manager() .get(logical_table_name) .await? - .context(TableNotFoundSnafu { - table_name: logical_table_name.to_string(), + .with_context(|| TableNotFoundSnafu { + table_name: TableReference::from(logical_table_name).to_string(), }) .map(|table| table.table_id())?; diff --git a/src/common/meta/src/key/table_name.rs b/src/common/meta/src/key/table_name.rs index a632e3a23398..e508c5e87764 100644 --- a/src/common/meta/src/key/table_name.rs +++ b/src/common/meta/src/key/table_name.rs @@ -21,6 +21,7 @@ use serde::{Deserialize, Serialize}; use snafu::OptionExt; use table::metadata::TableId; use table::table_name::TableName; +use table::table_reference::TableReference; use super::{MetadataKey, MetadataValue, TABLE_NAME_KEY_PATTERN, TABLE_NAME_KEY_PREFIX}; use crate::error::{Error, InvalidMetadataSnafu, Result}; @@ -122,6 +123,16 @@ impl From> for TableName { } } +impl<'a> From> for TableReference<'a> { + fn from(value: TableNameKey<'a>) -> Self { + Self { + catalog: value.catalog, + schema: value.schema, + table: value.table, + } + } +} + impl<'a> TryFrom<&'a str> for TableNameKey<'a> { type Error = Error;