betodealmeida opened a new pull request #12821: URL: https://github.com/apache/superset/pull/12821
### SUMMARY <!--- Describe the change below, including rationale and design decisions --> When running a statement in SQL Lab, after the query is finished we first close the cursor and then close the connection (using the `closing` context manager). This raises an exception in BigQuery due to a bug (https://github.com/googleapis/python-bigquery/issues/497), and while the exception is captured it pollutes the logs, creating an error entry for every statement executed. I created a PR fixing the bug upstream (https://github.com/googleapis/python-bigquery/pull/498), but in the meantime we can prevent this from happening by simply not closing the cursor explicitly. This is possible because closing a connection will close all its cursors (the exception in BigQuery happens because it tries to close the already closed cursor). This means we can replace this: ```python with closing(engine.raw_connection()) as conn: with closing(conn.cursor()) as cursor: cursor.execute(sql) ``` With: ```python with closing(engine.raw_connection()) as conn: cursor = conn.cursor() cursor.execute(sql) ``` With this change, BigQuery will no longer try to close the closed cursor, keeping the logs clean. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> N/A ### TEST PLAN <!--- What steps should be taken to verify the changes --> Ran a simple query in BigQuery, and verified that the error message no longer shows up in the logs. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Changes UI - [ ] Requires DB Migration. - [ ] Confirm DB Migration upgrade and downgrade tested. - [ ] Introduces new feature or API - [ ] Removes existing feature or API ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
