Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
from .record_batch import RecordBatch, RecordBatchStream
from .udf import Accumulator, AggregateUDF, ScalarUDF, WindowUDF, udaf, udf, udwf

ctx = SessionContext()

__version__ = importlib_metadata.version(__name__)

__all__ = [
Expand All @@ -76,6 +78,7 @@
"col",
"column",
"common",
"ctx",
"expr",
"functions",
"lit",
Expand Down
13 changes: 13 additions & 0 deletions python/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ def test_create_context_no_args():
SessionContext()


def test_default_ctx_instance():
"""Test that the default ctx instance works correctly"""
from datafusion import SessionContext, ctx

# Test that ctx is an instance of SessionContext
assert isinstance(ctx, SessionContext)

# Test basic functionality
df = ctx.sql("SELECT 1 as num")
result = df.collect()
assert len(result) == 1


def test_create_context_session_config_only():
SessionContext(config=SessionConfig())

Expand Down