Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaApi supports multi tenant #3759

Closed
Tracked by #3740 ...
BohuTANG opened this issue Jan 4, 2022 · 3 comments · Fixed by #3790
Closed
Tracked by #3740 ...

MetaApi supports multi tenant #3759

BohuTANG opened this issue Jan 4, 2022 · 3 comments · Fixed by #3790
Assignees
Labels
A-meta Area: databend meta serive C-feature Category: feature

Comments

@BohuTANG
Copy link
Member

BohuTANG commented Jan 4, 2022

Summary

It seems MetaApi is a global view, can not get a tenant database/table:

impl MetaApi for MetaRemote {
async fn create_database(&self, req: CreateDatabaseReq) -> Result<CreateDatabaseReply> {
self.query_backend(move |cli| async move { cli.create_database(req).await })
.await
}
async fn drop_database(&self, req: DropDatabaseReq) -> Result<DropDatabaseReply> {
self.query_backend(move |cli| async move { cli.drop_database(req).await })
.await
}
async fn get_database(&self, req: GetDatabaseReq) -> Result<Arc<DatabaseInfo>> {
self.query_backend(move |cli| async move { cli.get_database(req).await })
.await
}
async fn list_databases(&self, req: ListDatabaseReq) -> Result<Vec<Arc<DatabaseInfo>>> {
self.query_backend(move |cli| async move { cli.list_databases(req).await })
.await
}
async fn create_table(&self, req: CreateTableReq) -> Result<CreateTableReply> {
// TODO validate plan by table engine first
self.query_backend(move |cli| async move { cli.create_table(req).await })
.await
}
async fn drop_table(&self, req: DropTableReq) -> Result<DropTableReply> {
self.query_backend(move |cli| async move { cli.drop_table(req).await })
.await
}
async fn get_table(&self, req: GetTableReq) -> Result<Arc<TableInfo>> {
self.query_backend(move |cli| async move { cli.get_table(req).await })
.await
}
async fn list_tables(&self, req: ListTableReq) -> Result<Vec<Arc<TableInfo>>> {
self.query_backend(move |cli| async move { cli.list_tables(req).await })
.await
}
async fn get_table_by_id(&self, table_id: MetaId) -> Result<(TableIdent, Arc<TableMeta>)> {
self.query_backend(move |cli| async move { cli.get_table_by_id(table_id).await })
.await
}
async fn upsert_table_option(
&self,
req: UpsertTableOptionReq,
) -> Result<UpsertTableOptionReply> {
self.query_backend(move |cli| async move { cli.upsert_table_option(req).await })
.await
}
fn name(&self) -> String {
"meta-remote".to_owned()
}
}

The KVApi works well with a prefix.

@BohuTANG BohuTANG added C-feature Category: feature A-meta Area: databend meta serive labels Jan 4, 2022
@ariesdevil ariesdevil self-assigned this Jan 4, 2022
@drmingdrmer
Copy link
Member

With tenant id, the namespace for a table would be tenant_id/user_id/database/table or tenant_id/database/table?
I.e., is it legal that two user have database with the same database name?

@ariesdevil
Copy link
Collaborator

IMO yes, two tenants can have the same database name and a tenant can have multiple users.
Correct me if I was wrong.

@BohuTANG
Copy link
Member Author

BohuTANG commented Jan 4, 2022

For databend use case, tenant_id/database/table is ok, there is no user_id from catelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: databend meta serive C-feature Category: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants