snowflake-connector-python icon indicating copy to clipboard operation
snowflake-connector-python copied to clipboard

SNOW-199087: Implement multi-statement support for the Python connector.

Open sfc-gh-heshah opened this issue 3 years ago • 0 comments

SNOW-676491: Executing multiple queries with no complications.

SNOW-676495: Execute multiple queries with parameter bindings.

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

    Fixes SNOW-199087

  2. Fill out the following pre-review checklist:

    • [x] I am adding a new automated test(s) to verify correctness of my new code
    • [ ] I am adding new logging messages
    • [ ] I am adding a new telemetry message
    • [ ] I am modifying authorization mechanisms
    • [ ] I am adding new credentials
    • [ ] I am modifying OCSP code
    • [ ] I am adding a new dependency
  3. Please describe how your code solves the related issue.

    When submitting a multi-statement query, GS returns a payload in which resultIds corresponding to each of the individual queries are provided. Even if the parameter (account, session, or statement level) MULTI_STATEMENT_COUNT is not 1 (other options allow multi-statement results), GS will still return the regular payload without resultIds, allowing the connector to determine whether the query submitted was multi-statement or not after inspecting the payload. I added several data members to the cursor class allowing the storage and retrieval of submitted query IDs. The exec_async functionality will also work the same way as it does for single statements (users are expected to call get_results_by_sfqid when they want to retrieve results of an asynchronous multi-statement query. Using the stored query IDs and the query_result method, the connector can set the cursor to achieve the same ready state for calling fetch*() after calling nextset() to iterate through the result sets of each query in the submitted multi-statement.

sfc-gh-heshah avatar Oct 14 '22 22:10 sfc-gh-heshah