epgif commented on code in PR #16401:
URL: https://github.com/apache/datafusion/pull/16401#discussion_r2153345514


##########
datafusion/catalog/src/schema.rs:
##########
@@ -54,6 +55,14 @@ pub trait SchemaProvider: Debug + Sync + Send {
         name: &str,
     ) -> Result<Option<Arc<dyn TableProvider>>, DataFusionError>;
 
+    /// Retrieves the type of a specific table from the schema by name, if it 
exists, otherwise
+    /// returns `None`.  Implementations for which this operation is cheap but 
[Self::table] is
+    /// expensive can override this to improve operations that only need the 
type, e.g.
+    /// `SELECT * FROM information_schema.tables`.
+    async fn table_type(&self, name: &str) -> Result<Option<TableType>, 
DataFusionError> {
+        self.table(name).await.map(|o| o.map(|t| t.table_type()))

Review Comment:
   Well, clippy suggested what I had to begin with:
   
   ```
   warning: using `Result.and_then(|x| Ok(y))`, which is more succinctly 
expressed as `map(|x| y)`
     --> datafusion/catalog/src/schema.rs:63:9
      |
   63 | /         self.table(name)
   64 | |             .await
   65 | |             .and_then(|o| Ok(o.map(|t| t.table_type())))
      | |________________________________________________________^
      |
      = help: for further information visit 
https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map
      = note: `#[warn(clippy::bind_instead_of_map)]` on by default
   help: try
      |
   63 ~         self.table(name)
   64 +             .await.map(|o| o.map(|t| t.table_type()))
   ```
   
   So I changed it back.
   



-- 
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-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to