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-1559272: get_results_from_sfqid(query_id) vs query_result(query_id) #2009

Closed
copdips opened this issue Jul 26, 2024 · 3 comments · Fixed by #2055
Closed

SNOW-1559272: get_results_from_sfqid(query_id) vs query_result(query_id) #2009

copdips opened this issue Jul 26, 2024 · 3 comments · Fixed by #2055
Assignees
Labels
feature status-triage_done Initial triage done, will be further handled by the driver team

Comments

@copdips
Copy link

copdips commented Jul 26, 2024

What is the current behavior?

In the doc, it only talks about cursor.get_results_from_sfqid(query_id)

What is the desired behavior?

we need a clarification on the difference between cursor.get_results_from_sfqid(query_id) and cursor.query_result(query_id)

How would this improve snowflake-connector-python?

to let people know how to use these functions in different use cases.

References and other background

No response

@github-actions github-actions bot changed the title get_results_from_sfqid(query_id) vs query_result(query_id) SNOW-1559272: get_results_from_sfqid(query_id) vs query_result(query_id) Jul 26, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Aug 19, 2024
@sfc-gh-sghosh sfc-gh-sghosh added the status-triage Issue is under initial triage label Aug 19, 2024
@sfc-gh-sghosh
Copy link

sfc-gh-sghosh commented Aug 21, 2024

Hello @copdips ,

Thanks for raising the issue, we are checking with team, I am getting identical results for both of them.

`import snowflake.connector

snowflake_config = {
"account": "account",
"user": "xxxx",
"role": "accountadmin",
"password": "xxxxxx,
"warehouse": "WH",
"database": "SAMPLEDATABASE",
"schema": "TEST",
}

with snowflake.connector.connect(**snowflake_config) as con:

main_cursor1 = con.cursor(snowflake.connector.cursor.DictCursor)
print("cursor1 created")
main_cursor2 = con.cursor(snowflake.connector.cursor.DictCursor)
print("cursor2 created")

# Step 1: Execute a query using Snowpark and retrieve the query ID
#query = "SELECT * FROM MYCSVTABLE LIMIT 10"

#main_cursor.execute(query)

# Retrieve the query ID from the cursor object
#query_id = main_cursor.sfqid
query_id='01b67f09-080b-11df-0000-164926dfee9a'
print(f"Query ID: {query_id}")

main_cursor1.get_results_from_sfqid(query_id)
results = main_cursor1.fetchall()

# Print results
for row in results:
    print(row)

print("---------------------\n")
main_cursor2.query_result(query_id)
result_data = main_cursor2.fetchall()

# Print the query result
for row in result_data:
    print(row)

Output:

Query ID: 01b67f09-080b-11df-0000-164926dfee9a

`
{'SEQ': 1, 'LAST_NAME': 'AAAAAAA', 'FIRST_NAME': 'Maxwell'}
{'SEQ': 2, 'LAST_NAME': 'AAABBB', 'FIRST_NAME': 'Craig'}
{'SEQ': 3, 'LAST_NAME': 'newuser', 'FIRST_NAME': 'zxxzx'}
{'SEQ': 4, 'LAST_NAME': 'forthuser', 'FIRST_NAME': 'forthlast'}
{'SEQ': 1, 'LAST_NAME': 'AAAAAAA', 'FIRST_NAME': 'Maxwell'}
{'SEQ': 1, 'LAST_NAME': 'AAAAAAA', 'FIRST_NAME': 'Maxwell'}
{'SEQ': 2, 'LAST_NAME': 'AAABBB', 'FIRST_NAME': 'Craig'}
{'SEQ': 3, 'LAST_NAME': 'newuser', 'FIRST_NAME': 'zxxzx'}
{'SEQ': 4, 'LAST_NAME': 'forthuser', 'FIRST_NAME': 'forthlast'}
{'SEQ': 1, 'LAST_NAME': 'Maxwell', 'FIRST_NAME': 'AAAAAAA'}

{'SEQ': 1, 'LAST_NAME': 'AAAAAAA', 'FIRST_NAME': 'Maxwell'}
{'SEQ': 2, 'LAST_NAME': 'AAABBB', 'FIRST_NAME': 'Craig'}
{'SEQ': 3, 'LAST_NAME': 'newuser', 'FIRST_NAME': 'zxxzx'}
{'SEQ': 4, 'LAST_NAME': 'forthuser', 'FIRST_NAME': 'forthlast'}
{'SEQ': 1, 'LAST_NAME': 'AAAAAAA', 'FIRST_NAME': 'Maxwell'}
{'SEQ': 1, 'LAST_NAME': 'AAAAAAA', 'FIRST_NAME': 'Maxwell'}
{'SEQ': 2, 'LAST_NAME': 'AAABBB', 'FIRST_NAME': 'Craig'}
{'SEQ': 3, 'LAST_NAME': 'newuser', 'FIRST_NAME': 'zxxzx'}
{'SEQ': 4, 'LAST_NAME': 'forthuser', 'FIRST_NAME': 'forthlast'}
{'SEQ': 1, 'LAST_NAME': 'Maxwell', 'FIRST_NAME': 'AAAAAAA'}
`

Regards,
Sujan

@copdips
Copy link
Author

copdips commented Aug 21, 2024

It is precisely because the results of these two methods are the same that I would like to ask what specific differences there are between them.
Why SF provides 2 methods doing the same thing ?
If there're some differences, could you please document them ?

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage labels Sep 12, 2024
@sfc-gh-sghosh
Copy link

Hello @copdips ,

Sure, will work on modifying the documentation.

Regards,
Sujan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants