databend icon indicating copy to clipboard operation
databend copied to clipboard

feat: add into database trait Table API

Open lichuang opened this issue 2 years ago • 1 comments

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

feat: add into database trait Table API, each table API of catalog MUST first get a Database trait.

Fixes https://github.com/datafuselabs/databend/issues/7819

lichuang avatar Sep 23 '22 09:09 lichuang

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) Sep 26, 2022 at 1:17PM (UTC)

vercel[bot] avatar Sep 23 '22 09:09 vercel[bot]

Can you give some explanation about why getting a Table has to be done via a Database?

In order to support share database query tables.

In API such as catalog.get_table(tenant, db_name, table_name), catalog just pass (tenant,db_name,table_name) to meta, if it is a normal table, it will works fine.

But if (tenant,db_name,table_name) is a shared table, it may happen that this meta service has no share table meta.

So we need to add table API into Database trait, move all Table API in catalog route to Database trait.

Take the catalog.get_table(tenant, db_name, table_name) API for example:

  1. first get Database trait impl(now has only default database impl, but there will be share database impl for Database trait).
  2. And if found Database is a share database, the share database impl for Database trait will route the table request to the meta which the provider located.

lichuang avatar Sep 24 '22 08:09 lichuang

Take the catalog.get_table(tenant, db_name, table_name) API for example:

  1. first get Database trait impl(now has only default database impl, but there will be share database impl for Database trait).
  2. And if found Database is a share database, the share database impl for Database trait will route the table request to the meta which the provider located.

There are two types related to a database: one is about the data a DB has, i.e., the DatabaseMeta, and the other is about the behavior a DB provides, i.e., dyn Database.

To get a table, the catalog only needs the data part of a DB, not the behavior part.

Binding get-table functions to dyn Database introduces unnecessary coupling. I am not quite sure it will work.

drmingdrmer avatar Sep 25 '22 02:09 drmingdrmer