Skip to content

Commit 2fb8c07

Browse files
committed
Add ctx = SessionContext() to
1 parent 7c1c08f commit 2fb8c07

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

python/datafusion/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
from .record_batch import RecordBatch, RecordBatchStream
5151
from .udf import Accumulator, AggregateUDF, ScalarUDF, WindowUDF, udaf, udf, udwf
5252

53+
ctx = SessionContext()
54+
5355
__version__ = importlib_metadata.version(__name__)
5456

5557
__all__ = [
@@ -76,6 +78,7 @@
7678
"col",
7779
"column",
7880
"common",
81+
"ctx",
7982
"expr",
8083
"functions",
8184
"lit",

python/tests/test_context.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ def test_create_context_no_args():
3636
SessionContext()
3737

3838

39+
def test_default_ctx_instance():
40+
"""Test that the default ctx instance works correctly"""
41+
from datafusion import SessionContext, ctx
42+
43+
# Test that ctx is an instance of SessionContext
44+
assert isinstance(ctx, SessionContext)
45+
46+
# Test basic functionality
47+
df = ctx.sql("SELECT 1 as num")
48+
result = df.collect()
49+
assert len(result) == 1
50+
51+
3952
def test_create_context_session_config_only():
4053
SessionContext(config=SessionConfig())
4154

0 commit comments

Comments
 (0)