Skip to content
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

SNOW-1649210: Fix a bug where using to_pandas_batches with async jobs caused an error due to improper handling of waiting for asynchronous query completion. #2211

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Fixed a bug in `session.get_session_stage` that referenced a non-existing stage after switching database or schema.
- Fixed a bug where calling `DataFrame.to_snowpark_pandas_dataframe` without explicitly initializing the Snowpark pandas plugin caused an error.
- Fixed a bug where using the `explode` function in dynamic table creation caused a SQL compilation error due to improper boolean type casting on the `outer` parameter.
- Fixed a bug where using `to_pandas_batches` with async jobs caused an error due to improper handling of waiting for asynchronous query completion.

### Snowpark Local Testing Updates

Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/_internal/server_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _to_data_or_iter(
qid = results_cursor.sfqid
if to_iter:
new_cursor = results_cursor.connection.cursor()
new_cursor.execute(f"SELECT * FROM TABLE(RESULT_SCAN('{qid}'))")
new_cursor.get_results_from_sfqid(qid)
results_cursor = new_cursor

if to_pandas:
Expand Down
13 changes: 13 additions & 0 deletions tests/integ/scala/test_async_job_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,16 @@ def test_async_job_result_wait_no_result(session):
t1 = time()
assert t1 - t0 >= 3.0
assert result is None


@pytest.mark.parametrize(
"action",
[
lambda df: df.to_local_iterator(block=False),
lambda df: df.to_pandas_batches(block=False),
],
)
def test_iter_cursor_wait_for_result(session, action):
df = session.sql("call system$wait(5)")
async_job = action(df)
assert async_job.result() is not None
Loading