Return a [`TableProvider`] for the specified table.
(
&self,
table_ref: impl Into<TableReference>,
)
| 1995 | |
| 1996 | /// Return a [`TableProvider`] for the specified table. |
| 1997 | pub async fn table_provider( |
| 1998 | &self, |
| 1999 | table_ref: impl Into<TableReference>, |
| 2000 | ) -> Result<Arc<dyn TableProvider>> { |
| 2001 | let table_ref = table_ref.into(); |
| 2002 | let table = table_ref.table().to_string(); |
| 2003 | let schema = self.state.read().schema_for_ref(table_ref)?; |
| 2004 | match schema.table(&table).await? { |
| 2005 | Some(ref provider) => Ok(Arc::clone(provider)), |
| 2006 | _ => plan_err!("No table named '{table}'"), |
| 2007 | } |
| 2008 | } |
| 2009 | |
| 2010 | /// Get a new TaskContext to run in this session |
| 2011 | pub fn task_ctx(&self) -> Arc<TaskContext> { |