Skip to content

Commit

Permalink
SNOW-1058663 Fix ServerConnection. _to_data_or_iter to return the o…
Browse files Browse the repository at this point in the history
…riginal query id (#1260)

* Return original query ID

* Address comments
  • Loading branch information
sfc-gh-stan authored Feb 21, 2024
1 parent 8bd21d2 commit be8ebcd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/snowflake/snowpark/_internal/server_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,12 @@ def _to_data_or_iter(
to_pandas: bool = False,
to_iter: bool = False,
) -> Dict[str, Any]:
qid = results_cursor.sfqid
if (
to_iter and not to_pandas
): # Fix for SNOW-869536, to_pandas doesn't have this issue, SnowflakeCursor.fetch_pandas_batches already handles the isolation.
new_cursor = results_cursor.connection.cursor()
new_cursor.execute(
f"SELECT * FROM TABLE(RESULT_SCAN('{results_cursor.sfqid}'))"
)
new_cursor.execute(f"SELECT * FROM TABLE(RESULT_SCAN('{qid}'))")
results_cursor = new_cursor

if to_pandas:
Expand Down Expand Up @@ -481,7 +480,7 @@ def _to_data_or_iter(
iter(results_cursor) if to_iter else results_cursor.fetchall()
)

return {"data": data_or_iter, "sfqid": results_cursor.sfqid}
return {"data": data_or_iter, "sfqid": qid}

def execute(
self,
Expand Down

0 comments on commit be8ebcd

Please sign in to comment.