Skip to content

Commit

Permalink
feat: re-implement SessionContext::tables
Browse files Browse the repository at this point in the history
The method was removed upstream but is used in many tests for `datafusion-python`.

Ref: apache/datafusion#9627
  • Loading branch information
Michael-J-Ward committed May 8, 2024
1 parent f93b78f commit 5ec79ac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,18 @@ impl PySessionContext {
}

pub fn tables(&self) -> HashSet<String> {
#[allow(deprecated)]
self.ctx.tables().unwrap()
self.ctx
.catalog_names()
.into_iter()
.filter_map(|name| self.ctx.catalog(&name))
.flat_map(move |catalog| {
catalog
.schema_names()
.into_iter()
.filter_map(move |name| catalog.schema(&name))
})
.flat_map(|schema| schema.table_names())
.collect()
}

pub fn table(&self, name: &str, py: Python) -> PyResult<PyDataFrame> {
Expand Down

0 comments on commit 5ec79ac

Please sign in to comment.