-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[task #8917] Implement information_schema.schemata #8993
Conversation
@JanKaul |
0d3a573
to
6785b69
Compare
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 @Tangruilin
I think CI is failing due to the changes in datafusion/sqllogictest/test_files/aggregates_topk.slt
Which is due to #8845
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.
Great work! Thanks for the effort.
If I understand correctly the default_character_set_catalog
, default_character_set_schema
, default_character_set_name
, sql_path
columns are not required. So null is okay.
let schema_owner = match std::env::var("USER") { | ||
Ok(user) => user, | ||
Err(_) => match std::env::var("USERNAME") { | ||
Ok(user) => user, | ||
Err(_) => "".to_owned(), | ||
}, | ||
}; |
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'm not really sure about using the environment variables for the schema owner. I guess datafusion doesn't really have the concept of an user and therefore an owner. However, this is a required column and should somehow have a value. Similar to the default catalog we could use "datafusion" here.
@alamb what do you think?
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.
Now I get the System User from environment variables, which is same as postgresql.
Maybe you will have some good suggestions? It seems that datafusion do not have a user
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 agree pulling from the environment is not consistent with how the rest of DataFusion works. I think the owner should come from the SchemaProvider
However there is no notion of owner
on SchemaProvider
now
Thus, I suggest either:
- Leaving owner
NULL
for now - Add a function to the
SchemaProvider
to optionally provide a an owner
For example
trait SchemaProvider {
// return the "schema owner" of known, reported in `information_schema.schemata`
// Returns `None` by default
fn owner_name(&self) -> Option<&str> {
None
}
}
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 @Tangruilin and @JanKaul -- would it be possible to add a test that actually selects values from information_schema.schemata
in datafusion/sqllogictest/test_files/information_schema.slt (to test the values)?
let schema_owner = match std::env::var("USER") { | ||
Ok(user) => user, | ||
Err(_) => match std::env::var("USERNAME") { | ||
Ok(user) => user, | ||
Err(_) => "".to_owned(), | ||
}, | ||
}; |
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 agree pulling from the environment is not consistent with how the rest of DataFusion works. I think the owner should come from the SchemaProvider
However there is no notion of owner
on SchemaProvider
now
Thus, I suggest either:
- Leaving owner
NULL
for now - Add a function to the
SchemaProvider
to optionally provide a an owner
For example
trait SchemaProvider {
// return the "schema owner" of known, reported in `information_schema.schemata`
// Returns `None` by default
fn owner_name(&self) -> Option<&str> {
None
}
}
I will try this |
How is this PR going? I think it just needs
|
I will submit a new PR later or tomorrow |
I have done that ~~~ |
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 good to me, thank you for working on 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 great to me -- thank you @Tangruilin and @JanKaul -- I had some small comment suggestions but I don't think they are needed to merge this PR (they can be done as a follow on PR or never)
Thanks again!
@@ -34,6 +34,11 @@ use crate::error::{DataFusionError, Result}; | |||
/// [`CatalogProvider`]: super::CatalogProvider | |||
#[async_trait] | |||
pub trait SchemaProvider: Sync + Send { | |||
/// Returns the owner of the Schema, default is None |
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.
/// Returns the owner of the Schema, default is None | |
/// Returns the owner of the Schema, default is None. This value is reported | |
/// as part of `information_tables.schemata` |
Some(owner) => self.schema_owner.append_value(owner), | ||
None => self.schema_owner.append_null(), | ||
} | ||
// refer to https://www.postgresql.org/docs/current/infoschema-schemata.html, these rows are Applies to a feature not available |
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.
// refer to https://www.postgresql.org/docs/current/infoschema-schemata.html, these rows are Applies to a feature not available | |
// refer to https://www.postgresql.org/docs/current/infoschema-schemata.html, | |
// these rows apply to a feature that is not implemented in DataFusion |
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.
You can merge it, and i will submit a PR tomorrow to fix these.
Now it is 12:30 here, i may sleep, so sorry ~~~
Yes, no worries, go to 💤 !! We can wait until tomorrow there is no need for you to lose sleep or to rush in the PR It is part of being a distributed community |
Signed-off-by: tangruilin <[email protected]>
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 again @Tangruilin ❤️
Which issue does this PR close?
Closes #8917 .
Rationale for this change
What changes are included in this PR?
There are some in
infomation_schema.rs
Are these changes tested?
Yes
Are there any user-facing changes?
There will be a new table named
schemata
, users canselect * from information_schema.schemata;
to get info in it