Skip to content

Commit c70968f

Browse files
committed
Update documentation
1 parent 937d39c commit c70968f

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

python/datafusion/catalog.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@ def table(self, name: str) -> Table:
130130
return Table(self._raw_schema.table(name))
131131

132132
def register_table(
133-
self, name: str, table: Table | TableProviderExportable | Any
133+
self,
134+
name: str,
135+
table: Table | TableProviderExportable | DataFrame | pa.dataset.Dataset,
134136
) -> None:
135-
"""Register a table or table provider in this schema.
136-
137-
Objects implementing ``__datafusion_table_provider__`` are also supported
138-
and treated as table provider instances.
139-
"""
137+
"""Register a table in this schema."""
140138
return self._raw_schema.register_table(name, table)
141139

142140
def deregister_table(self, name: str) -> None:
@@ -155,8 +153,7 @@ class Table:
155153
__slots__ = ("_inner",)
156154

157155
def __init__(
158-
self,
159-
table: DataFrame | TableProviderExportable | pa.dataset.Dataset,
156+
self, table: Table | TableProviderExportable | DataFrame | pa.dataset.Dataset
160157
) -> None:
161158
"""Wrap a low level table or table provider."""
162159
self._inner = df_internal.catalog.RawTable(table)

python/datafusion/context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,9 @@ def register_view(self, name: str, df: DataFrame) -> None:
750750
self.ctx.register_table(name, view)
751751

752752
def register_table(
753-
self, name: str, table: Table | TableProviderExportable | Any
753+
self,
754+
name: str,
755+
table: Table | TableProviderExportable | DataFrame | pa.dataset.Dataset,
754756
) -> None:
755757
"""Register a :py:class:`~datafusion.Table` with this context.
756758

src/table.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ use crate::dataframe::PyDataFrame;
2424
use crate::dataset::Dataset;
2525
use crate::utils::table_provider_from_pycapsule;
2626

27+
/// This struct is used as a common method for all TableProviders,
28+
/// whether they refer to an FFI provider, an internally known
29+
/// implementation, a dataset, or a dataframe view.
2730
#[pyclass(name = "RawTable", module = "datafusion.catalog", subclass)]
2831
#[derive(Clone)]
2932
pub struct PyTable {
@@ -38,6 +41,15 @@ impl PyTable {
3841

3942
#[pymethods]
4043
impl PyTable {
44+
/// Instantiate from any Python object that supports any of the table
45+
/// types. We do not know a priori when using this method if the object
46+
/// will be passed a wrapped or raw class. Here we handle all of the
47+
/// following object types:
48+
///
49+
/// - PyTable (essentially a clone operation), but either raw or wrapped
50+
/// - DataFrame, either raw or wrapped
51+
/// - FFI Table Providers via PyCapsule
52+
/// - PyArrow Dataset objects
4153
#[new]
4254
pub fn new(obj: &Bound<'_, PyAny>) -> PyResult<Self> {
4355
if let Ok(py_table) = obj.extract::<PyTable>() {

0 commit comments

Comments
 (0)