-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Prevent Views from replacing MVs #15622
Conversation
`isPrestoView` returns true for both regular views and Materialized Views, so it could have been possible for a view to replace a MV. This would have only been possible during a rare race condition since the engine also checks that an existing entity is not a MV before calling on the connector to create or replace the view.
CI hit: #13633 |
@@ -86,7 +88,9 @@ public void createView(ConnectorSession session, SchemaTableName schemaViewName, | |||
|
|||
Optional<io.trino.plugin.hive.metastore.Table> existing = metastore.getTable(schemaViewName.getSchemaName(), schemaViewName.getTableName()); | |||
if (existing.isPresent()) { | |||
if (!replace || !isPrestoView(existing.get())) { | |||
Table existingTable = existing.get(); | |||
boolean shouldReplace = isPrestoView(existingTable) && !isTrinoMaterializedView(existingTable.getTableType(), existingTable.getParameters()); |
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.
isPrestoView
returns true for both regular views and Materialized
Views, so it could have been possible for a view to replace a MV.
@raunaqmorarka why is that?
doesn't seem practical
on the code level, the MVs are handled pretty separately, so why would we want to conflate them?
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'm not sure if that was on purpose or an accident, but we've been setting the "presto view" flag for MVs since the initial implementation https://github.com/trinodb/trino/pull/4832/files#diff-0a3bb720afd0370525ff486d8d55d6140e766028d20c95c37e8d60f801790881R765
Maybe it was a shortcut to ensure that MVs get listed in the metadata listing for views.
I agree that a clear separation would be better going forward.
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.
@alexjo2144 would it be possible to fix isPrestoView so that it doesn't return true for MVs?
Can you run this as a separate PR, potentially obsoleting this one?
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 am following-up on this in #18570
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
Good bot.
@raunaqmorarka can we think about doing that separately and fix the bug here first? |
lol, just gonna reply here so it removes the stale label...carry on! |
@@ -86,7 +88,9 @@ public void createView(ConnectorSession session, SchemaTableName schemaViewName, | |||
|
|||
Optional<io.trino.plugin.hive.metastore.Table> existing = metastore.getTable(schemaViewName.getSchemaName(), schemaViewName.getTableName()); | |||
if (existing.isPresent()) { | |||
if (!replace || !isPrestoView(existing.get())) { | |||
Table existingTable = existing.get(); | |||
boolean shouldReplace = isPrestoView(existingTable) && !isTrinoMaterializedView(existingTable.getTableType(), existingTable.getParameters()); |
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.
@alexjo2144 would it be possible to fix isPrestoView so that it doesn't return true for MVs?
Can you run this as a separate PR, potentially obsoleting this one?
Description
isPrestoView
returns true for both regular views and Materialized Views, so it could have been possible for a view to replace a MV.This would have only been possible during a rare race condition since the engine also checks that an existing entity is not a MV before calling on the connector to create or replace the view.
Additional context and related issues
Noticed while reviewing: #15580
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: