Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/create-context.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
)
ctx = SessionContext(config, runtime)
print(ctx)

ctx = ctx.enable_url_table()
print(ctx)
12 changes: 12 additions & 0 deletions python/datafusion/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,22 @@

self.ctx = SessionContextInternal(config, runtime)

def enable_url_table(self) -> "SessionContext":

"""Control if local files can be queried as tables.

Returns:
A new :py:class:`SessionContext` object with url table enabled.
"""
klass = self.__class__
obj = klass.__new__(klass)
obj.ctx = self.ctx.enable_url_table()
return obj

def register_object_store(
self, schema: str, store: Any, host: str | None = None
) -> None:
"""Add a new object store into the session.

Check failure on line 490 in python/datafusion/context.py

View workflow job for this annotation

GitHub Actions / build

Ruff (D201)

python/datafusion/context.py:486:9: D201 No blank lines allowed before function docstring (found 1)

Args:
schema: The data source schema.
Expand Down
6 changes: 6 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ impl PySessionContext {
})
}

pub fn enable_url_table(&self) -> PyResult<Self> {
Ok(PySessionContext {
ctx: self.ctx.clone().enable_url_table(),
})
}

/// Register an object store with the given name
#[pyo3(signature = (scheme, store, host=None))]
pub fn register_object_store(
Expand Down
Loading