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

fix(20428): Address-Presto/Trino-Poll-Issue-Refactor #20434

Conversation

Thelin90
Copy link
Contributor

@Thelin90 Thelin90 commented Jun 19, 2022

SUMMARY

Change to modify TrinoEngineSpec inherit class PrestoEngineSpec to address bug when running against presto-trino.

Given issue:

Traceback (most recent call last):
  File "/app/superset/sql_lab.py", line 275, in execute_sql_statement
    db_engine_spec.handle_cursor(cursor, query, session)
  File "/app/superset/db_engine_specs/presto.py", line 970, in handle_cursor
    polled = cursor.poll()
AttributeError: 'Cursor' object has no attribute 'poll'

Bug

Raised issue: #20428

Slack conversation: https://apache-superset.slack.com/archives/C015WAZL0KH/p1655449901353689

Additional Info:

See quote:

@S Thelin
I don’t believe we can provide query stats given the way the Trino client is configured. Statistics are updated when fetch is called per here, however this also fetches results and we cannot advance the cursor in the handle_cursor method. There could be some trickery we could do, but I think it’s safer to simply fallback to the default method.

@john-bodley

@Thelin90 Thelin90 changed the title fix(20428)-Address-Presto/Trino-Poll-Issue-Refacto DRAFT: fix(20428)-Address-Presto/Trino-Poll-Issue-Refacto Jun 19, 2022
@Thelin90 Thelin90 changed the title DRAFT: fix(20428)-Address-Presto/Trino-Poll-Issue-Refacto DRAFT: fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor Jun 19, 2022
@Thelin90 Thelin90 force-pushed the fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor branch from e554e8c to a335ff1 Compare June 19, 2022 18:52
@Thelin90 Thelin90 marked this pull request as ready for review June 19, 2022 19:00
@Thelin90 Thelin90 changed the title DRAFT: fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor Jun 19, 2022
@Thelin90 Thelin90 changed the title fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor DRAFT: fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor Jun 19, 2022
@Thelin90 Thelin90 changed the title DRAFT: fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor Jun 19, 2022
Copy link
Member

@john-bodley john-bodley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for authoring the PR.

logger.info("Query %i: Finished", query_id)
break

completed_splits = float(stats.get("completedSplits"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
completed_splits = float(stats.get("completedSplits"))
completed_splits = float(stats["completedSplits"])

break

completed_splits = float(stats.get("completedSplits"))
total_splits = float(stats.get("totalSplits"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
total_splits = float(stats.get("totalSplits"))
total_splits = float(stats["totalSplits"])

@@ -949,11 +949,7 @@ def get_create_view(
sql = f"SHOW CREATE VIEW {schema}.{table}"
try:
cls.execute(cursor, sql)
polled = cursor.poll()
Copy link
Member

@john-bodley john-bodley Jun 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Thelin90 let me test this using Presto to ensure this works. I'll report back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed, via the /extra_table_metadata/<int:database_id>/<table_name>/<schema>/ route—which is invokes said method for views, that the method works as expected without the polling.

@@ -15,15 +15,20 @@
# specific language governing permissions and limitations
# under the License.
import logging
from typing import Any, Dict, Optional, TYPE_CHECKING
import time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should revert any of the now unnecessary imports.

@john-bodley john-bodley changed the title fix(20428)-Address-Presto/Trino-Poll-Issue-Refactor fix(20428): Address-Presto/Trino-Poll-Issue-Refactor Jun 19, 2022
@codecov
Copy link

codecov bot commented Jun 19, 2022

Codecov Report

Merging #20434 (210d611) into master (c2f01a6) will increase coverage by 0.00%.
The diff coverage is 76.92%.

@@           Coverage Diff           @@
##           master   #20434   +/-   ##
=======================================
  Coverage   66.70%   66.71%           
=======================================
  Files        1739     1739           
  Lines       65153    65161    +8     
  Branches     6899     6899           
=======================================
+ Hits        43462    43469    +7     
- Misses      19938    19939    +1     
  Partials     1753     1753           
Flag Coverage Δ
hive 53.70% <76.92%> (+0.01%) ⬆️
mysql 82.26% <76.92%> (+<0.01%) ⬆️
postgres 82.33% <76.92%> (+<0.01%) ⬆️
presto 53.56% <76.92%> (+0.01%) ⬆️
python 82.76% <76.92%> (+<0.01%) ⬆️
sqlite 82.12% <76.92%> (+<0.01%) ⬆️
unit 50.55% <76.92%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/db_engine_specs/presto.py 89.02% <ø> (+0.32%) ⬆️
superset/db_engine_specs/trino.py 89.18% <76.92%> (-2.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2f01a6...210d611. Read the comment docs.

@john-bodley john-bodley merged commit 8b7262f into apache:master Jun 19, 2022
michael-s-molina pushed a commit that referenced this pull request Jun 23, 2022
* fix(20428)-Address-Presto/Trino-Poll-Issue-Refacto
r

Update linter

* Update to only use BaseEngineSpec handle_cursor

* Fix CI

Co-authored-by: John Bodley <[email protected]>
(cherry picked from commit 8b7262f)
michael-s-molina pushed a commit that referenced this pull request Aug 30, 2022
* fix(20428)-Address-Presto/Trino-Poll-Issue-Refacto
r

Update linter

* Update to only use BaseEngineSpec handle_cursor

* Fix CI

Co-authored-by: John Bodley <[email protected]>
@mistercrunch mistercrunch added 🍒 1.5.2 🍒 1.5.3 🍒 2.0.0 🍒 2.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v2.0 🍒 1.5.2 🍒 1.5.3 🍒 2.0.0 🍒 2.0.1 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants