Skip to content

Commit b534319

Browse files
committed
Add table provider capsule to PyTableProvider
1 parent a8cfa58 commit b534319

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/dataframe.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use datafusion::error::DataFusionError;
3434
use datafusion::execution::SendableRecordBatchStream;
3535
use datafusion::parquet::basic::{BrotliLevel, Compression, GzipLevel, ZstdLevel};
3636
use datafusion::prelude::*;
37+
use datafusion_ffi::table_provider::FFI_TableProvider;
3738
use futures::{StreamExt, TryStreamExt};
3839
use pyo3::exceptions::PyValueError;
3940
use pyo3::prelude::*;
@@ -60,7 +61,7 @@ use crate::{
6061
// this is an interim implementation
6162
#[pyclass(name = "TableProvider", module = "datafusion")]
6263
pub struct PyTableProvider {
63-
provider: Arc<dyn TableProvider>,
64+
provider: Arc<dyn TableProvider + Send>,
6465
}
6566

6667
impl PyTableProvider {
@@ -74,6 +75,21 @@ impl PyTableProvider {
7475
}
7576
}
7677

78+
#[pymethods]
79+
impl PyTableProvider {
80+
fn __datafusion_table_provider__<'py>(
81+
&self,
82+
py: Python<'py>,
83+
) -> PyResult<Bound<'py, PyCapsule>> {
84+
let name = CString::new("datafusion_table_provider").unwrap();
85+
86+
let runtime = get_tokio_runtime().0.handle().clone();
87+
let provider = FFI_TableProvider::new(Arc::clone(&self.provider), false, Some(runtime));
88+
89+
PyCapsule::new(py, provider, Some(name.clone()))
90+
}
91+
}
92+
7793
/// Configuration for DataFrame display formatting
7894
#[derive(Debug, Clone)]
7995
pub struct FormatterConfig {

0 commit comments

Comments
 (0)