-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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(Trino): create PrestoBaseEngineSpec
base class to share common code between Trino and Presto
#21066
Conversation
PrestoBaseEngineSpec
base class to share common code between Trino and Presto
cc @villebro, @john-bodley |
4b86bf3
to
38d6438
Compare
Codecov Report
@@ Coverage Diff @@
## master #21066 +/- ##
==========================================
- Coverage 66.28% 66.21% -0.07%
==========================================
Files 1770 1770
Lines 67522 67574 +52
Branches 7177 7177
==========================================
- Hits 44754 44747 -7
- Misses 20934 20993 +59
Partials 1834 1834
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
441ab0a
to
6c4da3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Tested to work as expected on Trino with a few comments, LMKWYT.
superset/db_engine_specs/presto.py
Outdated
from sqlalchemy.orm import Session | ||
from sqlalchemy.sql.expression import ColumnClause, Select | ||
|
||
from superset import cache_manager, is_feature_enabled | ||
from superset.common.db_query_status import QueryStatus | ||
from superset.databases.utils import make_url_safe | ||
from superset.db_engine_specs.base import BaseEngineSpec, ColumnTypeMapping | ||
from superset.db_engine_specs.base import ColumnTypeMapping | ||
from superset.db_engine_specs.presto_base import PrestoBaseEngineSpec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could just as well keep PrestoBaseEngineSpec
in superset.db_engine_specs.presto
, like we do for PostgresBaseEngineSpec
, as it kinda keeps the list of modules in db_engine_specs
shorter. Not strongly opinionated here, but let's at least keep it consistent; if we do decide to break out the bases, then I'd prefer to do it in a follow-up refactor PR and doing the same for other specs, too.
@classmethod | ||
def get_table_names( | ||
cls, | ||
database: Database, | ||
inspector: Inspector, | ||
schema: Optional[str], | ||
) -> List[str]: | ||
return BaseEngineSpec.get_table_names( | ||
database=database, | ||
inspector=inspector, | ||
schema=schema, | ||
) | ||
|
||
@classmethod | ||
def get_view_names( | ||
cls, | ||
database: Database, | ||
inspector: Inspector, | ||
schema: Optional[str], | ||
) -> List[str]: | ||
return BaseEngineSpec.get_view_names( | ||
database=database, | ||
inspector=inspector, | ||
schema=schema, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also remove has_implicit_cancel
, as it's no longer needed (it returns the same as BaseEngineSpec
which isn't overridden in PrestoBaseEngineSpec
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_implicit_cancel
is removed
bcbd7d8
to
bbede4e
Compare
engine = "trino" | ||
engine_aliases = {"trinonative"} # Required for backwards compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trinonative
in setup.py
already removed since #20152
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM assuming CI doesn't turn up any goblins
…s between Presto and Trino Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
dedcacf
to
c759331
Compare
…code between Trino and Presto (apache#21066) * chore: create `PrestoBaseEngineSpec` class that share common functions between Presto and Trino Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> * feat(Trino): support CertificateAuthentication * chore(Presto): move `get_function_names` to `PrestoBaseEngineSpec` Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> * chores(Presto): remove `is_readonly_query` * feat(Trino): implement `extra_table_metadata` * feat(Trino): specify `User-Agent` Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> * fix: pylint Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> * chores(Presto): move `PrestoBaseEngineSpec` to `presto.py` Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> * fix(Presto): typing annotations Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> (cherry picked from commit ccb293a)
@dungdm93 and @villebro the issue I see with this approach is that it introduced several regressions (from a feature parity perspective; especially given that a migration path from Presto to Trino is somewhat likely—see here for details), i.e., the Are there plans to either:
|
@john-bodley the problem is that PyHive and the new Trino connector are diverging at a rapid pace right now, so extending the Trino spec from the old Presto spec is IMO not a good idea (that actually created a few regressions of its own when we did that). I'm fine moving everything that's known to work on both to |
@villebro understood. I'm 50/50 about whether option 1 or 2 is the preferred solution. Option 1 might be easiest for now (conditional on how coupled the logic is with the DB-API), but long term I sense option 2 is likely preferred. |
SUMMARY
#20152 Making the
TrinoEngineSpec
derive from thePrestoEngineSpec
to reusing code. However, underlay driver of Trino is different from Presto - PyHive which lead to some issues. (See discussion in #20729)This PR is rework on that PR by create
PrestoBaseEngineSpec
to share common functions between Presto variants.Fix:
Suppress:
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Unit tests
ADDITIONAL INFORMATION