You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by ti...@apache.org on 2025/01/08 21:39:35 UTC

(datafusion-python) branch main updated: feat: support enable_url_table config (#980)

This is an automated email from the ASF dual-hosted git repository.

timsaucer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 389164a  feat: support enable_url_table config (#980)
389164a is described below

commit 389164aa90c8dbe689f2e8eac0677ef2b80aaad9
Author: Chongchen Chen <ch...@qq.com>
AuthorDate: Thu Jan 9 05:39:31 2025 +0800

    feat: support enable_url_table config (#980)
    
    * feat: support enable_url_table config
    
    * change enable_url_table as method
    
    * Remove whitespace
    
    ---------
    
    Co-authored-by: Tim Saucer <ti...@gmail.com>
---
 examples/create-context.py   |  3 +++
 python/datafusion/context.py | 11 +++++++++++
 src/context.rs               |  6 ++++++
 3 files changed, 20 insertions(+)

diff --git a/examples/create-context.py b/examples/create-context.py
index 3184d40..11525d8 100644
--- a/examples/create-context.py
+++ b/examples/create-context.py
@@ -37,3 +37,6 @@ config = (
 )
 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 3fa1333..6d7f574 100644
--- a/python/datafusion/context.py
+++ b/python/datafusion/context.py
@@ -481,6 +481,17 @@ class SessionContext:
 
         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 0512285..88c90e0 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -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(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org