diff --git a/examples/create-context.py b/examples/create-context.py index 3184d4085..11525d8b8 100644 --- a/examples/create-context.py +++ b/examples/create-context.py @@ -37,3 +37,6 @@ ) ctx = SessionContext(config, runtime) print(ctx) + +ctx = ctx.enable_url_table() +print(ctx) diff --git a/python/datafusion/context.py b/python/datafusion/context.py index a07b5d175..e6ec261c0 100644 --- a/python/datafusion/context.py +++ b/python/datafusion/context.py @@ -472,6 +472,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: diff --git a/src/context.rs b/src/context.rs index 8675e97df..9420331bc 100644 --- a/src/context.rs +++ b/src/context.rs @@ -299,6 +299,12 @@ impl PySessionContext { }) } + pub fn enable_url_table(&self) -> PyResult { + 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(