You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Spaarsh (via GitHub)" <gi...@apache.org> on 2025/03/17 15:12:20 UTC

[PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Spaarsh opened a new pull request, #1072:
URL: https://github.com/apache/datafusion-python/pull/1072

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1065 
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   To improve ergonomics of the API by providing a pre-initialized `SessionContext` instance as `ctx`. This allows users to import and use a context directly without initialization.
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   - Added `ctx = SessionContext()` in `__init__.py` to provide a default context instance
   - Added corresponding test `test_default_ctx_instance` to verify functionality
   - Included `ctx` in `__all__` for explicit exports
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   Yes, users can now do:
   ```python
   from datafusion import ctx # Get pre-initialized context
   ```
   Instead of:
   ```
   from datafusion import SessionContext
   ctx = SessionContext()  # Manual initialization
   ```
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   It adds a new API for the users.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer commented on PR #1072:
URL: https://github.com/apache/datafusion-python/pull/1072#issuecomment-2743226539

   My question was more about ergonomics - now that we have the global context I suspect most users don't even need to import at all. In your use case, do you find you still need it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Posted by "deanm0000 (via GitHub)" <gi...@apache.org>.
deanm0000 commented on PR #1072:
URL: https://github.com/apache/datafusion-python/pull/1072#issuecomment-2743797814

   I see that the other PR makes functions for the file readers at the module level but AFAIK, there are still utilities only available through ctx. For example, we still have to do `ctx.from_pydict` rather than just `from_pydict`. I'm personally indifferent between having all those functions available from a module rather than an instantiated class or to have an instance of the initialized class available to import. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer closed pull request #1072: 1065/enhancement/add ctx to `__init__.py`
URL: https://github.com/apache/datafusion-python/pull/1072


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Posted by "deanm0000 (via GitHub)" <gi...@apache.org>.
deanm0000 commented on PR #1072:
URL: https://github.com/apache/datafusion-python/pull/1072#issuecomment-2741548913

   To address @timsaucer's point from the issue, what about doing
   
   ```python
   ctx = SessionContext.global_ctx()
   ```
   instead of just `ctx=SessionContext()`.
   
   I don't really know the internals so I don't know what the difference is but I did find `https://github.com/apache/datafusion-python/pull/1060/files` which makes that available.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer commented on PR #1072:
URL: https://github.com/apache/datafusion-python/pull/1072#issuecomment-2764532709

   I recommend closing this PR or at lest changing it to:
   
   ```python
   global_ctx = SessionContext.global_ctx()
   ```
   
   That *I think* will also help with making sure the naming is consistent.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] 1065/enhancement/add ctx to `__init__.py` [datafusion-python]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer commented on PR #1072:
URL: https://github.com/apache/datafusion-python/pull/1072#issuecomment-2970807273

   Closing since no activity. Please reopen PR if this continues to be a user's need.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org