-
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
Remove redundant checks from DropSchemaTask #11612
Remove redundant checks from DropSchemaTask #11612
Conversation
`listTables` includes views and materialized views, so calling `listViews` and `listMaterializedViews` is redundant.
* Get the relation names that match the specified table prefix (never null). | ||
* This includes all relations (e.g. tables, views, materialized views). |
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 did not check. Is this accurate for all the connector now?
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 went through all the implementations of io.trino.spi.connector.ConnectorMetadata#listViews
and io.trino.spi.connector.ConnectorMetadata#listMaterializedViews
and the corresponding listTables
implementation does indeed return the views / materialized views as well.
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 did not check. Is this accurate for all the connector now?
even if it wasn't the case yet, we already have this
trino/core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Lines 210 to 213 in 8b0c754
/** | |
* List table, view and materialized view names, possibly filtered by schema. An empty list is returned if none match. | |
*/ | |
default List<SchemaTableName> listTables(ConnectorSession session, Optional<String> schemaName) |
and Metadata just calls that method.
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.
Good direction but I don't think all connectors check for existence of materialized views.
All of them do check for views though.
We should also check if there are any connectors whose drop schema impl doens't check for existence of objects in the schema. (i.e. remote views or materialized views or other objects) (I'll check and re-review).
Personally I don't have an opinion here as I don't track whether all connectors consistently implement SPI. Isn't that change risky? |
@@ -92,19 +92,7 @@ private static boolean isSchemaEmpty(Session session, CatalogSchemaName schema, | |||
{ | |||
QualifiedTablePrefix tablePrefix = new QualifiedTablePrefix(schema.getCatalogName(), schema.getSchemaName()); | |||
|
|||
// These are best efforts checks that don't provide any guarantees against concurrent DDL operations |
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.
It would be beneficial to add views & materialized views in the io.trino.testing.BaseConnectorTest#testDropNonEmptySchema
depending on:
SUPPORTS_CREATE_VIEW
SUPPORTS_CREATE_MATERIALIZED_VIEW
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.
Good idea, but we would have to test all these 3 cases separately. I don't plan to do this though. Do you want to want to follow up?
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.
Yes, I'll create a PR based on your changes.
See #11614
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.
Yes, I'll create a PR based on your changes.
many thanks!
@hashhar I think exactly one connector supports MVs today, am i right? |
@findepi Yes, but how do you ensure this contract is maintained going forward without either tests or by default calling (Because I'm not confident we'll catch this at review time). |
Failure to list MVs within |
listTables
includes views and materialized views, so callinglistViews
andlistMaterializedViews
is redundant.