common_meta/ddl/alter_table/metadata.rs
1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use common_catalog::format_full_table_name;
16use snafu::OptionExt;
17
18use crate::ddl::alter_table::AlterTableProcedure;
19use crate::error::{self, Result};
20
21impl AlterTableProcedure {
22 /// Fetches the table info.
23 pub(crate) async fn fill_table_info(&mut self) -> Result<()> {
24 let table_id = self.data.table_id();
25 let alter_expr = &self.data.task.alter_table;
26 let catalog = &alter_expr.catalog_name;
27 let schema = &alter_expr.schema_name;
28 let table_name = &alter_expr.table_name;
29
30 let table_info_value = self
31 .context
32 .table_metadata_manager
33 .table_info_manager()
34 .get(table_id)
35 .await?
36 .with_context(|| error::TableNotFoundSnafu {
37 table_name: format_full_table_name(catalog, schema, table_name),
38 })?;
39 self.data.table_info_value = Some(table_info_value);
40 Ok(())
41 }
42}