You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/17 12:39:45 UTC
[GitHub] [arrow-datafusion] alamb commented on a change in pull request #1959: Add Create Schema functionality in SQL
alamb commented on a change in pull request #1959:
URL: https://github.com/apache/arrow-datafusion/pull/1959#discussion_r829069418
##########
File path: datafusion/src/execution/context.rs
##########
@@ -2907,6 +2947,29 @@ mod tests {
assert_eq!(Weak::strong_count(&catalog_weak), 0);
}
+ #[tokio::test]
+ async fn sql_create_schema() -> Result<()> {
+ // the information schema used to introduce cyclic Arcs
Review comment:
not sure what this comment means
##########
File path: datafusion/src/execution/context.rs
##########
@@ -286,6 +285,39 @@ impl ExecutionContext {
Ok(Arc::new(DataFrame::new(self.state.clone(), &plan)))
}
}
+ LogicalPlan::CreateCatalogSchema(CreateCatalogSchema {
+ schema_name,
+ if_not_exists,
+ ..
+ }) => {
+ // sqlparser doesnt accept database / catalog as parameter to CREATE SCHEMA
+ // so for now, we default to "datafusion" catalog
+ let default_catalog = "datafusion";
+ let catalog = self.catalog(default_catalog).ok_or_else(|| {
+ DataFusionError::Execution(String::from(
+ "Missing 'datafusion' catalog",
+ ))
+ })?;
+
+ let schema = catalog.schema(&schema_name);
+
+ match (if_not_exists, schema) {
Review comment:
👍
##########
File path: datafusion/src/execution/context.rs
##########
@@ -286,6 +285,39 @@ impl ExecutionContext {
Ok(Arc::new(DataFrame::new(self.state.clone(), &plan)))
}
}
+ LogicalPlan::CreateCatalogSchema(CreateCatalogSchema {
+ schema_name,
+ if_not_exists,
+ ..
+ }) => {
+ // sqlparser doesnt accept database / catalog as parameter to CREATE SCHEMA
Review comment:
maybe worth a ticket to sqlparser to support this? Or maybe just a PR :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org