-
Notifications
You must be signed in to change notification settings - Fork 473
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-1625324: execute_async()
+ get_results_from_sfqid()
has a naive error handler
#2026
Comments
execute_async()
+ get_results_from_sfqid()
has a naive error handlerexecute_async()
+ get_results_from_sfqid()
has a naive error handler
Hello @Kache , Thanks for raising the issue, we are investigating, will update. Regards, |
Hello @Kache , I just executed the code snippet in asynchronous mode with incorrect SQL statement and I am getting the query id and the proper error message, its not losing the SQL compilation error, run time error information etc.
ProgrammingError: 001003: 1003: SQL compilation error: |
In order to reproduce, can't use a query that "fails too quickly", where the failure is immediately available and immediately returned. Here's an example of a query that takes some execution time before failing: SELECT *
FROM (
SELECT SEQ4()::variant AS col
FROM TABLE(GENERATOR(ROWCOUNT => 1000000)) -- increase as needed
UNION
SELECT 'fail'::variant AS col -- fails at runtime when execution reaches this row
) a
JOIN (VALUES (1)) b(col) ON a.col::varchar::int = b.col Perhaps if the following
Let me put together a complete script |
Hello @Kache , Thanks for the update; we are working on it and will update you. Regards, |
Here is a cleaner repro than in the original post: runtime_fail_sql = """
SELECT *
FROM (
SELECT SEQ4()::variant AS col
FROM TABLE(GENERATOR(ROWCOUNT => 1000000)) -- increase as needed
UNION
SELECT 'fail'::variant AS col -- fails at runtime when execution reaches this row
) a
JOIN (VALUES (1)) b(col) ON a.col::varchar::int = b.col
"""
def full_error():
with snowflake.connector.connect(**creds) as conn:
with conn.cursor(cursor_class=snowflake.connector.cursor.DictCursor) as cur:
cur.execute(runtime_fail_sql)
# snowflake.connector.errors.ProgrammingError: 100038 (22018): 01b6a58e-0308-12f7-76fd-87015479a46b: Numeric value 'fail' is not
logging.info(cur.fetchall())
def async_naive_error():
with snowflake.connector.connect(**creds) as conn:
with conn.cursor(cursor_class=snowflake.connector.cursor.DictCursor) as cur:
cur.execute_async(runtime_fail_sql)
assert cur.sfqid
cur.get_results_from_sfqid(cur.sfqid)
results = cur.fetchall()
# snowflake.connector.errors.DatabaseError: Status of query '01b6a58e-0308-12f9-76fd-8701547996af' is FAILED_WITH_ERROR, results are unavailable
logging.info(results)
def async_full_error():
retry_pattern = it.chain(ASYNC_RETRY_PATTERN, it.repeat(ASYNC_RETRY_PATTERN[-1]))
with snowflake.connector.connect(**creds) as conn:
with conn.cursor(cursor_class=snowflake.connector.cursor.DictCursor) as cur:
cur.execute_async(runtime_fail_sql)
assert cur.sfqid
# custom wait loop, based on wait_until_ready() from cursor.get_results_from_sfqid()
while True:
status = cur.connection.get_query_status_throw_if_error(cur.sfqid)
# snowflake.connector.errors.ProgrammingError: 100038: 100038: Numeric value 'fail' is not recognized
if not cur.connection.is_still_running(status):
break
time.sleep(0.5 * next(retry_pattern))
cur.get_results_from_sfqid(cur.sfqid)
logging.info(cur.fetchall()) In other words, it seems like this line should instead call
|
hey @Kache , we have released v3.12.2 with the fix, could you try out the latest version? |
Python version
Python 3.11.4 (main, Jan 10 2024, 15:34:31) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Operating system and processor architecture
macOS-14.6-arm64-arm-64bit
Installed packages
What did you do?
What did you expect to see?
Expected to see the
use execute_async()
path above to behave similarly to theuse workaround
path:use execute_async()
use execute()
This can be done by replacing the naive query status/error handling in
wait_until_ready()
:snowflake-connector-python/src/snowflake/connector/cursor.py
Lines 1657 to 1662 in 416ff57
with the better query status/error handling of
get_query_status_throw_if_error()
:snowflake-connector-python/src/snowflake/connector/connection.py
Lines 1849 to 1872 in 416ff57
Can you set logging to DEBUG and collect the logs?
The text was updated successfully, but these errors were encountered: