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/21 18:25:59 UTC

[GitHub] [arrow-datafusion] alamb opened a new pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

alamb opened a new pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052


   Draft PR until https://github.com/apache/arrow-datafusion/pull/2050 is merged
   
   # Which issue does this PR close?
   
   Closes https://github.com/apache/arrow-datafusion/pulls
   
    # Rationale for this change
   
   We have a custom catalog implementation in IOx that implements `SchemaProvider`. However, in our usecase I don't want to allow users to register new schemas via SQL (and would like to return an Error about 'not supported')
   
   However, the current API only returns a `Option`:
   
   https://github.com/apache/arrow-datafusion/blob/3ec0d55c736aecef5051311e639836aecbde7f51/datafusion/src/catalog/catalog.rs#L150-L154
   
   # What changes are included in this PR?
   1. return a `Result<Option<.>>` and default the implementation to "registering new schemas is not supported"
   2. tests for same
   
   
   # Are there any user-facing changes?
   Yes, changes the API introduced by @matthewmturner in https://github.com/apache/arrow-datafusion/pull/1959 but that has not yet been released publically


-- 
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



[GitHub] [arrow-datafusion] yjshen commented on a change in pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

Posted by GitBox <gi...@apache.org>.
yjshen commented on a change in pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052#discussion_r832038608



##########
File path: datafusion/src/execution/context.rs
##########
@@ -2978,14 +2982,18 @@ mod tests {
         let schema_a = MemorySchemaProvider::new();
         schema_a
             .register_table("table_a".to_owned(), test::table_with_sequence(1, 1)?)?;
-        catalog_a.register_schema("schema_a", Arc::new(schema_a));
+        catalog_a
+            .register_schema("schema_a", Arc::new(schema_a))
+            .unwrap();

Review comment:
       ```suggestion
               .register_schema("schema_a", Arc::new(schema_a))?;
   ```




-- 
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



[GitHub] [arrow-datafusion] yjshen merged pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

Posted by GitBox <gi...@apache.org>.
yjshen merged pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052


   


-- 
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



[GitHub] [arrow-datafusion] alamb commented on pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052#issuecomment-1074264205


   cc @doki23 


-- 
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



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052#discussion_r832032134



##########
File path: datafusion/src/catalog/catalog.rs
##########
@@ -110,12 +111,23 @@ pub trait CatalogProvider: Sync + Send {
     fn schema(&self, name: &str) -> Option<Arc<dyn SchemaProvider>>;
 
     /// Adds a new schema to this catalog.
-    /// If a schema of the same name existed before, it is replaced in the catalog and returned.
+    ///
+    /// If a schema of the same name existed before, it is replaced in
+    /// the catalog and returned.
+    ///
+    /// By default returns a "Not Implemented" error
     fn register_schema(
         &self,
         name: &str,
         schema: Arc<dyn SchemaProvider>,
-    ) -> Option<Arc<dyn SchemaProvider>>;
+    ) -> Result<Option<Arc<dyn SchemaProvider>>> {

Review comment:
       this is the change -- return `Result` here (and add a default impl that returns error)




-- 
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



[GitHub] [arrow-datafusion] alamb commented on pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052#issuecomment-1075017809


   FYI @matthewmturner 


-- 
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



[GitHub] [arrow-datafusion] yjshen commented on a change in pull request #2052: Allow `CatalogProvider::register_catalog` to return an error

Posted by GitBox <gi...@apache.org>.
yjshen commented on a change in pull request #2052:
URL: https://github.com/apache/arrow-datafusion/pull/2052#discussion_r832042398



##########
File path: datafusion/src/execution/context.rs
##########
@@ -2978,14 +2982,18 @@ mod tests {
         let schema_a = MemorySchemaProvider::new();
         schema_a
             .register_table("table_a".to_owned(), test::table_with_sequence(1, 1)?)?;
-        catalog_a.register_schema("schema_a", Arc::new(schema_a));
+        catalog_a
+            .register_schema("schema_a", Arc::new(schema_a))
+            .unwrap();
         ctx.register_catalog("catalog_a", Arc::new(catalog_a));
 
         let catalog_b = MemoryCatalogProvider::new();
         let schema_b = MemorySchemaProvider::new();
         schema_b
             .register_table("table_b".to_owned(), test::table_with_sequence(1, 2)?)?;
-        catalog_b.register_schema("schema_b", Arc::new(schema_b));
+        catalog_b
+            .register_schema("schema_b", Arc::new(schema_b))
+            .unwrap();

Review comment:
       ```suggestion
               .register_schema("schema_b", Arc::new(schema_b))?;
   ```

##########
File path: datafusion/src/execution/context.rs
##########
@@ -2978,14 +2982,18 @@ mod tests {
         let schema_a = MemorySchemaProvider::new();
         schema_a
             .register_table("table_a".to_owned(), test::table_with_sequence(1, 1)?)?;
-        catalog_a.register_schema("schema_a", Arc::new(schema_a));
+        catalog_a
+            .register_schema("schema_a", Arc::new(schema_a))
+            .unwrap();

Review comment:
       ```suggestion
               .register_schema("schema_a", Arc::new(schema_a))?;
   ```




-- 
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