From eec53286f2f11ea35a9bcf7bf7abc595e02efe97 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Tue, 20 Aug 2024 23:43:13 -0500 Subject: [PATCH] fix(datafusion): fix creation of SessionContext in datafusion 40.1.0 --- ibis/backends/datafusion/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ibis/backends/datafusion/__init__.py b/ibis/backends/datafusion/__init__.py index e53e8112c1da..fc8108602490 100644 --- a/ibis/backends/datafusion/__init__.py +++ b/ibis/backends/datafusion/__init__.py @@ -40,6 +40,11 @@ except ImportError: SessionConfig = None +try: + from datafusion import RuntimeConfig +except ImportError: + RuntimeConfig = None + if TYPE_CHECKING: import pandas as pd import polars as pl @@ -105,7 +110,12 @@ def do_connect( ).with_information_schema(True) else: df_config = None - self.con = SessionContext(df_config) + if RuntimeConfig is None: + self.con = SessionContext(df_config) + else: + # datafusion 40.1.0 has a bug where SessionContext requires + # both SessionConfig and RuntimeConfig be provided. + self.con = SessionContext(df_config, RuntimeConfig()) self._register_builtin_udfs()