8000 feat: support enable_url_table config (#980) · nirnayroy/datafusion-python@389164a · GitHub
[go: up one dir, main page]

Skip to content

Commit 389164a

Browse files
feat: support enable_url_table config (apache#980)
* feat: support enable_url_table config * change enable_url_table as method * Remove whitespace --------- Co-authored-by: Tim Saucer <timsaucer@gmail.com>
1 parent 63b13da commit 389164a

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

examples/create-context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@
3737
)
3838
ctx = SessionContext(config, runtime)
3939
print(ctx)
40+
41+
ctx = ctx.enable_url_table()
42+
print(ctx)

python/datafusion/context.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,17 @@ def __init__(
481481

482482
self.ctx = SessionContextInternal(config, runtime)
483483

484+
def enable_url_table(self) -> "SessionContext":
485+
"""Control if local files can be queried as tables.
486+
487+
Returns:
488+
A new :py:class:`SessionContext` object with url table enabled.
489+
"""
490+
klass = self.__class__
491+
obj = klass.__new__(klass)
492+
obj.ctx = self.ctx.enable_url_table()
493+
return obj
494+
484495
def register_object_store(
485496
self, schema: str, store: Any, host: str | None = None
486497
) -> None:

src/context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ impl PySessionContext {
299299
})
300300
}
301301

302+
pub fn enable_url_table(&self) -> PyResult<Self> {
303+
Ok(PySessionContext {
304+
ctx: self.ctx.clone().enable_url_table(),
305+
})
306+
}
307+
302308
/// Register an object store with the given name
303309
#[pyo3(signature = (scheme, store, host=None))]
304310
pub fn register_object_store(

0 commit comments

Comments
 (0)
0