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

Trino Engine Specs Producing Duplicate Table/View Items in SQL Lab UI #20752

Closed
3 tasks
zac-roberts opened this issue Jul 18, 2022 · 4 comments
Closed
3 tasks
Labels
#bug Bug report

Comments

@zac-roberts
Copy link

zac-roberts commented Jul 18, 2022

After adding Trino as a source database, the user could experience error messages in the SQL Lab UI due to duplicated table/view names in the SQL Lab SQL Editor "See Table Schema" drop down. I believe this is related to a similar issue that was handled for Presto ... however may not have been addressed as part of this refactoring.

Ultimately, it looks like in the db_engine_specs/trino.py the functions get_table_names() and get_view_names() both return the same identical list which generates duplicates in the UI. This could be due to the fact that the following SQL Alchemy example returns the exact same list for both tables and views when working with Trino (tables will have same elements as views):

from sqlalchemy import create_engine
from sqlalchemy import inspect

create engine from a URL and params
create inspector for engine

tables = inspector.get_table_names(schema)
views = inspector.get_view_names(schema)

I believe this has been handled for Presto but not Trino. The Trino engine spec inherits from the Presto engine spec however the Trino spec overrides the get_table_names and get_view_names functions by calling the default functions on the base engine object. One option might be to leverage the functions in the Presto spec. Another option might be to code the Trino functions similarly to what has been done for Presto.

How to reproduce the bug

  1. Go to Data -> Databases.
  2. Click button to Add Database "+ Database"
  3. Choose Trino from supported databases and add a Trino datasource.
  4. After succesfully adding a Trino datasource, navigate to SQL Lab -> SQL Editor.
  5. In the database dropdown, choose the Trino datasource you added.
  6. Refresh the schema drop down
  7. Observe duplicates and potentially error messages in "See Table Schema" drop down.

Expected results

Would not expect to see duplicate entries for each table/view in the See Table Schema dropdown.

Actual results

Duplicate entires for each table/view in the See Table Schema dropdown.

Screenshots

Coming soon.

Environment

Coming soon.

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

I believe this has been handled for Presto but not Trino. The Trino engine spec inherits from the Presto engine spec however the Trino spec overrides the get_table_names and get_view_names functions by calling the default functions on the base engine object. One option might be to leverage the functions in the Presto spec. Another option might be to code the Trino functions similarly to what has been done for Presto.

@zac-roberts zac-roberts added the #bug Bug report label Jul 18, 2022
@dungdm93
Copy link
Contributor

#20152

@john-bodley
Copy link
Member

john-bodley commented Jul 22, 2022

Per here the Trino SQLAlchemy dialect should handle fetching table and view names separately.

@zac-roberts
Copy link
Author

Thanks... I'll take another look and report back.

@rusackas
Copy link
Member

rusackas commented Feb 9, 2024

Based on the above thread and PR, I'm assuming this is solved. Correct me if I'm mistaken!

@rusackas rusackas closed this as completed Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report
Projects
None yet
Development

No branches or pull requests

4 participants