10000 1065/enhancement/add ctx to `__init__.py` by Spaarsh · Pull Request #1072 · apache/datafusion-python · GitHub
[go: up one dir, main page]

Skip to content

1065/enhancement/add ctx to __init__.py #1072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments. Retry
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
0