snowpark-python icon indicating copy to clipboard operation
snowpark-python copied to clipboard

SNOW-1342243: Call getOrCreate at package import time so that sproc user does not need to

Open sfc-gh-helmeleegy opened this issue 1 year ago • 2 comments

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1342243

  2. Fill out the following pre-review checklist:

    • [ ] I am adding a new automated test(s) to verify correctness of my new code
      • [ ] If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • [ ] I am adding new logging messages
    • [ ] I am adding a new telemetry message
    • [ ] I am adding new credentials
    • [ ] I am adding a new dependency
    • [ ] If this is a new feature/behavior, I'm adding the Local Testing parity changes.
  3. Please describe how your code solves the related issue.

    Call getOrCreate at package import time so that sproc user does not need to.

sfc-gh-helmeleegy avatar Jul 12 '24 19:07 sfc-gh-helmeleegy

This change seems dangerous to me. Here are some scenarios that might break:

  • What happens when a user does not have credentials configured before importing this package.
  • What happens if the user ignores the default session and creates their own, then calls something that references get_active_session?
  • What happens if a user imports this package while using local testing mode?

These are all good points @sfc-gh-jrose. Do you think that they will be addressed after this other PR is merged? In this case, calling getOrCreate will actually get rather than create. Also, is there a way to detect if we are in a local testing mode, such that we can skip this workaround?

sfc-gh-helmeleegy avatar Jul 15 '24 22:07 sfc-gh-helmeleegy

These are all good points @sfc-gh-jrose. Do you think that they will be addressed after this other PR is merged? In this case, calling getOrCreate will actually get rather than create. Also, is there a way to detect if we are in a local testing mode, such that we can skip this workaround?

With the code now gated by is_in_stored_procedure I don't think local testing is a concern.

sfc-gh-jrose avatar Jul 16 '24 16:07 sfc-gh-jrose