Skip to content

Commit

Permalink
refactor: remove unused TableInfo.tenant (#16416)
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer authored Sep 7, 2024
1 parent fb6e250 commit 6253e83
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 25 deletions.
8 changes: 1 addition & 7 deletions src/meta/api/src/schema_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,6 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?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(),
};
Expand Down Expand Up @@ -1745,18 +1744,14 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?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(),
table_id_list_key.table_name,
),
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(),
})
Expand Down Expand Up @@ -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(),
};
Expand Down
9 changes: 0 additions & 9 deletions src/meta/api/src/schema_api_test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
};

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 0 additions & 2 deletions src/meta/api/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
};
Expand Down
2 changes: 0 additions & 2 deletions src/meta/app/src/schema/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CatalogInfo>,

Expand Down
2 changes: 0 additions & 2 deletions src/query/service/src/databases/default/default_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
})
Expand Down
4 changes: 1 addition & 3 deletions src/query/service/src/locks/table_lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +49,7 @@ impl Lock for TableLock {
ctx: Arc<dyn TableContext>,
should_retry: bool,
) -> Result<Option<Arc<LockGuard>>> {
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(),
Expand Down

0 comments on commit 6253e83

Please sign in to comment.