andygrove commented on code in PR #2438:
URL: https://github.com/apache/arrow-datafusion/pull/2438#discussion_r864281525


##########
datafusion/core/src/execution/context.rs:
##########
@@ -1364,10 +1364,16 @@ impl SessionState {
 }
 
 impl ContextProvider for SessionState {
-    fn get_table_provider(&self, name: TableReference) -> Option<Arc<dyn 
TableProvider>> {
+    fn get_table_provider(&self, name: TableReference) -> Result<Arc<dyn 
TableProvider>> {
         let resolved_ref = self.resolve_table_ref(name);
-        let schema = self.schema_for_ref(resolved_ref).ok()?;
-        schema.table(resolved_ref.table)
+        let schema = self.schema_for_ref(resolved_ref).unwrap();
+        match schema.table(resolved_ref.table) {
+            Some(e) => Ok(e),
+            None => Err(DataFusionError::Plan(format!(
+                "Table with name '{}' not found",
+                name.table()
+            ))),
+        }

Review Comment:
   nit: We could make this more concise using `ok_or_else`
   
   ```suggestion
           schema.table(resolved_ref.table).ok_or_else(|| {
               DataFusionError::Plan(format!("Table with name '{}' not found", 
name.table()))
           })
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to