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

ISSUE #3206: Support SHOW ENGINES Statement #4050

Merged
merged 4 commits into from
Feb 6, 2022

Conversation

SGZW
Copy link
Contributor

@SGZW SGZW commented Feb 4, 2022

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

Summary

solve #3206

Changelog

  • New Feature

Related Issues

Test Plan

Unit Tests

Stateless Tests

@SGZW SGZW requested a review from BohuTANG as a code owner February 4, 2022 08:07
@databend-bot databend-bot added the pr-feature this PR introduces a new feature to the codebase label Feb 4, 2022
@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

1 similar comment
@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@vercel
Copy link

vercel bot commented Feb 4, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/databend/databend/HLnFm1JT5om6fhkDULtw8UKJtEph
✅ Preview: Canceled

[Deployment for 01c0fc0 canceled]

let mut engine_support = Vec::with_capacity(1);
let mut engine_comment = Vec::with_capacity(1);
// fuse engine
engine_name.push("FUSE".as_bytes());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the engines information from the StorageFactory :\

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let me fix it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we should add desc() to StorageCreator as the comment column:

pub trait StorageCreator: Send + Sync {
    fn try_create(&self, ctx: StorageContext, table_info: TableInfo) -> Result<Box<dyn Table>>;
    fn desc(&self) -> &str;
}

#[derive(Default)]
pub struct StorageFactory {
creators: RwLock<HashMap<String, Arc<dyn StorageCreator>>>,
descriptors: Vec<StorageDescriptor>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the descriptor idea.
I think StorageDescriptor should be a part of table engine, it explicitly tell what this engine is, as defined by the engine's module not the Factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if every table engine implementes StorageCreateor trait and StorageCreator add interface desc() to return StorageDescriptor?

Copy link
Member

@BohuTANG BohuTANG Feb 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if every table engine implementes StorageCreateor trait and StorageCreator add interface desc() to return StorageDescriptor?

Agreed.

Update:
It seems we only need add desc() function to the StorageCreator.

pub fn create(table_id: u64) -> Self {
let schema = DataSchemaRefExt::create(vec![
DataField::new("Engine", DataType::String, false),
DataField::new("Support", DataType::String, false),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove the Support column here, when the engine who is not registered to the factory it means we don't want it to show up, this is a bit different from MySQL engines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

_ctx: Arc<QueryContext>,
_plan: &ReadDataSourcePlan,
) -> Result<SendableDataBlockStream> {
let descriptors = _ctx.get_catalog().get_storage_descriptors();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we add StorageDescriptor to catalog and impl it for every table engine, how about get the table engine name and descriptor from self.ctx.storage_factory?
It seems we only add a function like desc()->&str for the table engine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i don't get the real meaning of this. can you explain it more clearly? i think every engine should has it's own creator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason of why we add StorageDescriptor to catalog is that storage_factory is only MutableCatalog's member variable,so database catalog should expose a api to get descriptors, or we can get descriptors from storage_factory and construct the EnginesTable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descrptor is Attributes of engine,so I impl it for every table engine...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about only add one function like description() to table engine instead of the Descriptior trait? And we register the description to storage factory, this looks more clearly.
Then we can add one trait function named 'get_table_engines' to Catalog, which getting the engine details from the mutable catalog.

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2022

Codecov Report

Merging #4050 (01c0fc0) into main (76e831b) will increase coverage by 0%.
The diff coverage is 76%.

Impacted file tree graph

@@          Coverage Diff           @@
##            main   #4050    +/-   ##
======================================
  Coverage     57%     57%            
======================================
  Files        821     825     +4     
  Lines      43468   43623   +155     
======================================
+ Hits       24805   24931   +126     
- Misses     18663   18692    +29     
Impacted Files Coverage Δ
query/src/catalogs/catalog.rs 29% <0%> (-3%) ⬇️
query/src/sql/sql_statement.rs 30% <0%> (-1%) ⬇️
query/src/sql/statements/analyzer_statement.rs 90% <0%> (-1%) ⬇️
query/src/sql/statements/statement_show_engines.rs 0% <0%> (ø)
query/src/storages/storage_factory.rs 78% <80%> (-3%) ⬇️
query/src/storages/fuse/table.rs 93% <83%> (-1%) ⬇️
query/src/storages/github/github_table.rs 8% <83%> (+8%) ⬆️
query/src/storages/memory/memory_table.rs 96% <83%> (-1%) ⬇️
query/src/storages/null/null_table.rs 90% <83%> (-1%) ⬇️
query/src/storages/system/engines_table.rs 88% <88%> (ø)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76e831b...01c0fc0. Read the comment docs.

@BohuTANG
Copy link
Member

BohuTANG commented Feb 6, 2022

/lgtm
Thank you @SGZW !

@BohuTANG BohuTANG merged commit c340c45 into databendlabs:main Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants