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.
I did not check. Is this accurate for all the connector now?
There was a problem hiding this comment.
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.
I did not check. Is this accurate for all the connector now?
even if it wasn't the case yet, we already have this
and Metadata just calls that method.
There was a problem hiding this comment.
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? |
| { | ||
| 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.
It would be beneficial to add views & materialized views in the io.trino.testing.BaseConnectorTest#testDropNonEmptySchema depending on:
SUPPORTS_CREATE_VIEWSUPPORTS_CREATE_MATERIALIZED_VIEW
There was a problem hiding this comment.
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.
Yes, I'll create a PR based on your changes.
See #11614
There was a problem hiding this comment.
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 |
listTablesincludes views and materialized views, so callinglistViewsandlistMaterializedViewsis redundant.