-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Prevent Views from replacing MVs #15622
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import io.trino.plugin.hive.metastore.Column; | ||
| import io.trino.plugin.hive.metastore.HiveMetastore; | ||
| import io.trino.plugin.hive.metastore.PrincipalPrivileges; | ||
| import io.trino.plugin.hive.metastore.Table; | ||
| import io.trino.spi.TrinoException; | ||
| import io.trino.spi.connector.ConnectorSession; | ||
| import io.trino.spi.connector.ConnectorViewDefinition; | ||
|
|
@@ -38,6 +39,7 @@ | |
| import static io.trino.plugin.hive.TrinoViewUtil.createViewProperties; | ||
| import static io.trino.plugin.hive.ViewReaderUtil.encodeViewData; | ||
| import static io.trino.plugin.hive.ViewReaderUtil.isPrestoView; | ||
| import static io.trino.plugin.hive.ViewReaderUtil.isTrinoMaterializedView; | ||
| import static io.trino.plugin.hive.metastore.MetastoreUtil.buildInitialPrivilegeSet; | ||
| import static io.trino.plugin.hive.metastore.PrincipalPrivileges.NO_PRIVILEGES; | ||
| import static io.trino.plugin.hive.metastore.StorageFormat.VIEW_STORAGE_FORMAT; | ||
|
|
@@ -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()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@raunaqmorarka why is that? doesn't seem practical
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i am following-up on this in #18570 |
||
| if (!replace || !shouldReplace) { | ||
| throw new ViewAlreadyExistsException(schemaViewName); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.