-
Notifications
You must be signed in to change notification settings - Fork 3.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
Add ConnectorMetadata#isMaterializedView #18933
Conversation
CI #16437 |
please add a test for that
is this also an optimization? if so, there should be a test change (eg counting file system or metastore access) that shows the improvement. |
The description contradicts that. |
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Outdated
Show resolved
Hide resolved
There are already changes to the |
TestTrinoDatabaseMetaData is quite tied to JDBC driver see eg Lines 328 to 372 in 8f25ce5
|
Sure, I'm working on tests right now (though demonstrating how a corrupted metadata can prevent |
20f0aeb
to
64cafd6
Compare
The current implementation of `MetadataManager#isMaterializedView` calls `ConnectorMetadata#getMaterializedView` under the covers. This means that we have to load and deserialize the materialized view metadata just to see if it exists, which is unnecessary most of the time. This may also cause issues when the metadata is currupted in some way (see subsequent commits for relevant test cases, where we add support for this method to the Iceberg plugin). In such a case, we want to still be able to `DROP` the corrupted materialized view - which is currently impossible, because the `DropMaterializedViewTask` will call `getMaterializedView`, which will fail when it tries to load the corrupted metadata. With this change this is less likely.
Here it's mostly just an optimization, which allows us to avoid loading the materialized view metadata unnecessarily in some situations.
64cafd6
to
3e5d566
Compare
@findepi Addressed comments, PTAL. |
Added such a test, but it's not very meaningful, IMO. It just says that we call |
Added a release note. |
Finally found a way to do that; test added.
I rewrote the commit message (and the PR description) to phrase it as primarily a correctness issue, with some efficiency improvements added as a bonus. |
See #19177 for an example of a failure that this PR can mitigate. |
3e5d566
to
632751a
Compare
This commit adds, among other things, test cases where we `DROP` materialized view with corrupted metadata, which would otherwise fail. In case of Hive catalogs we can bypass the metadata cache entirely, in case of Glue catalogs the benefits are not that pronounced. But we still avoid some potentially expensive operations and/or ones potentially causing failures.
632751a
to
f5d848b
Compare
/test-with-secrets sha=f5d848b3678109c4fe1e67b18b798d5c0e1ee04e |
i plan to review this (later) |
The CI workflow run with tests that require additional secrets finished as failure: https://github.com/trinodb/trino/actions/runs/6352010690 |
This is true, but actually it is probably much lesser problem than it sounds it is
The
This is important not only for |
It is a problem, at least, for the use case I'm trying to fix.
That's true as well. I appreciate the feedback and I agree that we don't want to add more code which may be considered a workaround for limitations of the current architecture, but I also don't want this to become a case of "sure, but first please spend 6 months refactoring this complex piece of code". What would be the commended course of action then? |
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
This work is currently on hold and it's not clear this is the way forward. I'll reopen if it crystalizes. |
Description
The current implementation of
MetadataManager#isMaterializedView
callsConnectorMetadata#getMaterializedView
under the covers. This means that we have to load and deserialize the materialized view metadata just to see if it exists, which is unnecessary most of the time. This may also cause issues when the metadata is currupted in some way (see the last commit for relevant test cases, where we add support for this method to the Iceberg plugin). In such a case, we want to still be able toDROP
the corrupted materialized view - which is currently impossible, because theDropMaterializedViewTask
will callgetMaterializedView
, which will fail when it tries to load the corrupted metadata. With this change this is less likely.Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: