From 28c12a1d67d81b11da8d9aef49d2cbd57d25218f Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Tue, 20 Aug 2024 10:45:03 -0500 Subject: [PATCH] Fix SessionContext init with only SessionConfig Previously creating a `SessionContext` when specifying only a `SessionConfig` would error. --- python/datafusion/context.py | 2 +- python/datafusion/tests/test_context.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python/datafusion/context.py b/python/datafusion/context.py index 922cc87a3..0c9b1d176 100644 --- a/python/datafusion/context.py +++ b/python/datafusion/context.py @@ -445,7 +445,7 @@ def __init__( df = ctx.read_csv("data.csv") """ config = config.config_internal if config is not None else None - runtime = runtime.config_internal if config is not None else None + runtime = runtime.config_internal if runtime is not None else None self.ctx = SessionContextInternal(config, runtime) diff --git a/python/datafusion/tests/test_context.py b/python/datafusion/tests/test_context.py index 8373659b0..16de2588f 100644 --- a/python/datafusion/tests/test_context.py +++ b/python/datafusion/tests/test_context.py @@ -38,6 +38,14 @@ def test_create_context_no_args(): SessionContext() +def test_create_context_session_config_only(): + SessionContext(config=SessionConfig()) + + +def test_create_context_runtime_config_only(): + SessionContext(runtime=RuntimeConfig()) + + @pytest.mark.parametrize("path_to_str", (True, False)) def test_runtime_configs(tmp_path, path_to_str): path1 = tmp_path / "dir1"