Skip to content

Commit

Permalink
feat: support enable_url_table config (#980)
Browse files Browse the repository at this point in the history
* feat: support enable_url_table config

* change enable_url_table as method

* Remove whitespace

---------

Co-authored-by: Tim Saucer <[email protected]>
  • Loading branch information
chenkovsky and timsaucer authored Jan 8, 2025
1 parent 63b13da commit 389164a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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)
11 changes: 11 additions & 0 deletions python/datafusion/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,17 @@ def __init__(

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:
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

0 comments on commit 389164a

Please sign in to comment.