diff --git a/src/meta/api/src/schema_api_impl.rs b/src/meta/api/src/schema_api_impl.rs index e26c40bfb77e..5cb8d7dc5591 100644 --- a/src/meta/api/src/schema_api_impl.rs +++ b/src/meta/api/src/schema_api_impl.rs @@ -1634,7 +1634,6 @@ impl + ?Sized> SchemaApi for KV { ), name: tenant_dbname_tbname.table_name.clone(), meta: seq_meta.data, - tenant: req.tenant.tenant_name().to_string(), db_type, catalog_info: Default::default(), }; @@ -1745,10 +1744,7 @@ impl + ?Sized> SchemaApi for KV { .into_iter() .map(|(table_id, seqv)| { Arc::new(TableInfo { - ident: TableIdent { - table_id: table_id.table_id, - seq: seqv.seq(), - }, + ident: TableIdent::new(table_id.table_id, seqv.seq()), desc: format!( "'{}'.'{}'", tenant_dbname.database_name(), @@ -1756,7 +1752,6 @@ impl + ?Sized> SchemaApi for KV { ), name: table_id_list_key.table_name.to_string(), meta: seqv.data, - tenant: tenant_dbname.tenant_name().to_string(), db_type: DatabaseType::NormalDB, catalog_info: Default::default(), }) @@ -3852,7 +3847,6 @@ async fn batch_filter_table_info( ), name: table_name.clone(), meta: tb_meta, - tenant: db_ident.tenant_name().to_string(), db_type: DatabaseType::NormalDB, catalog_info: Default::default(), }; diff --git a/src/meta/api/src/schema_api_test_suite.rs b/src/meta/api/src/schema_api_test_suite.rs index 2ccc3472e753..957ed4862dbc 100644 --- a/src/meta/api/src/schema_api_test_suite.rs +++ b/src/meta/api/src/schema_api_test_suite.rs @@ -1663,7 +1663,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get created table"); @@ -1686,7 +1685,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get created table"); @@ -1719,7 +1717,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get old table"); @@ -1804,7 +1801,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_eq!(got.1.data.created_on, want.meta.created_on); @@ -2292,7 +2288,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db1_name, tb3_name), name: tb3_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; @@ -2430,7 +2425,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db2_name, tb3_name), name: tb3_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get renamed table"); @@ -2514,7 +2508,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get created table"); @@ -3168,7 +3161,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get created table"); @@ -5423,7 +5415,6 @@ impl SchemaApiTestSuite { desc: format!("'{}'.'{}'", db_name, tbl_name), name: tbl_name.into(), meta: table_meta(created_on), - tenant: tenant_name.to_string(), ..Default::default() }; assert_meta_eq_without_updated!(want, got.as_ref().clone(), "get created table"); diff --git a/src/meta/api/src/util.rs b/src/meta/api/src/util.rs index 01c02f5b9924..3e5ba52adf8a 100644 --- a/src/meta/api/src/util.rs +++ b/src/meta/api/src/util.rs @@ -33,7 +33,6 @@ use databend_common_meta_app::schema::TableIdent; use databend_common_meta_app::schema::TableInfo; use databend_common_meta_app::schema::TableMeta; use databend_common_meta_app::schema::TableNameIdent; -use databend_common_meta_app::KeyWithTenant; use databend_common_meta_kvapi::kvapi; use databend_common_meta_kvapi::kvapi::DirName; use databend_common_meta_kvapi::kvapi::Key; @@ -552,7 +551,6 @@ pub async fn get_tableinfos_by_ids( desc: format!("'{}'.'{}'", tenant_dbname.database_name(), tbl_names[i]), meta: tbl_meta, name: tbl_names[i].clone(), - tenant: tenant_dbname.tenant_name().to_string(), db_type: db_type.clone(), catalog_info: Default::default(), }; diff --git a/src/meta/app/src/schema/table.rs b/src/meta/app/src/schema/table.rs index 41f93bb308ac..c2ea03d7a793 100644 --- a/src/meta/app/src/schema/table.rs +++ b/src/meta/app/src/schema/table.rs @@ -194,8 +194,6 @@ pub struct TableInfo { /// `name`, `id` or `version` is not included in the table structure definition. pub meta: TableMeta, - pub tenant: String, - /// The corresponding catalog info of this table. pub catalog_info: Arc, diff --git a/src/query/service/src/databases/default/default_database.rs b/src/query/service/src/databases/default/default_database.rs index 62e35429beed..4280b6b239e0 100644 --- a/src/query/service/src/databases/default/default_database.rs +++ b/src/query/service/src/databases/default/default_database.rs @@ -44,7 +44,6 @@ use databend_common_meta_app::schema::UpdateMultiTableMetaReq; use databend_common_meta_app::schema::UpdateMultiTableMetaResult; use databend_common_meta_app::schema::UpsertTableOptionReply; use databend_common_meta_app::schema::UpsertTableOptionReq; -use databend_common_meta_app::KeyWithTenant; use databend_common_meta_types::SeqValue; use crate::databases::Database; @@ -170,7 +169,6 @@ impl Database for DefaultDatabase { ), name: table_name.to_string(), meta: seqv.data, - tenant: self.db_info.name_ident.tenant_name().to_string(), db_type: DatabaseType::NormalDB, catalog_info: Default::default(), }) diff --git a/src/query/service/src/locks/table_lock/mod.rs b/src/query/service/src/locks/table_lock/mod.rs index f1fec79ed8ff..2203b94ff796 100644 --- a/src/query/service/src/locks/table_lock/mod.rs +++ b/src/query/service/src/locks/table_lock/mod.rs @@ -20,8 +20,6 @@ use databend_common_exception::Result; use databend_common_meta_app::schema::LockKey; use databend_common_meta_app::schema::LockType; use databend_common_meta_app::schema::TableInfo; -use databend_common_meta_app::tenant::Tenant; -use databend_common_meta_types::anyerror::func_name; use databend_common_pipeline_core::LockGuard; use crate::locks::LockManager; @@ -51,7 +49,7 @@ impl Lock for TableLock { ctx: Arc, should_retry: bool, ) -> Result>> { - let tenant = Tenant::new_or_err(&self.table_info.tenant, func_name!())?; + let tenant = ctx.get_tenant(); let table_id = self.table_info.ident.table_id; let lock_key = LockKey::Table { tenant: tenant.clone(),