-
Notifications
You must be signed in to change notification settings - Fork 742
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
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.
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 :\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 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