ISSUE #3206: Support SHOW ENGINES Statement#4050
Conversation
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
1 similar comment
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/databend/databend/HLnFm1JT5om6fhkDULtw8UKJtEph [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()); |
There was a problem hiding this comment.
Let's get the engines information from the StorageFactory :\
There was a problem hiding this comment.
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
what if every table engine implementes StorageCreateor trait and StorageCreator add interface desc() to return StorageDescriptor?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
| _ctx: Arc<QueryContext>, | ||
| _plan: &ReadDataSourcePlan, | ||
| ) -> Result<SendableDataBlockStream> { | ||
| let descriptors = _ctx.get_catalog().get_storage_descriptors(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Descrptor is Attributes of engine,so I impl it for every table engine...
There was a problem hiding this comment.
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 Report
@@ Coverage Diff @@
## main #4050 +/- ##
======================================
Coverage 57% 57%
======================================
Files 821 825 +4
Lines 43468 43623 +155
======================================
+ Hits 24805 24931 +126
- Misses 18663 18692 +29
Continue to review full report at Codecov.
|
|
/lgtm |
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
solve #3206
Changelog
Related Issues
Test Plan
Unit Tests
Stateless Tests