-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Refactor is*View ViewReaderUtil methods #18570
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
0b79e1d
f637594
edcd875
335c414
a85df69
a094339
3360465
c340dc8
4ea0a43
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 |
|---|---|---|
|
|
@@ -39,7 +39,7 @@ | |
| import static io.trino.plugin.hive.TableType.VIRTUAL_VIEW; | ||
| 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.isTrinoView; | ||
| 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; | ||
|
|
@@ -87,7 +87,7 @@ 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())) { | ||
|
Member
Author
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. In theory, the old code could replace an MV with a View (see #15622)
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. Could we add a test to verify it isn't allowed now ?
Member
Author
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. it would be very hard to write such a test. from linked PR desc
|
||
| if (!replace || !isTrinoView(existing.get())) { | ||
| throw new ViewAlreadyExistsException(schemaViewName); | ||
| } | ||
|
|
||
|
|
@@ -168,7 +168,6 @@ public Optional<ConnectorViewDefinition> getView(SchemaTableName viewName) | |
| } | ||
| return metastore.getTable(viewName.getSchemaName(), viewName.getTableName()) | ||
| .flatMap(view -> TrinoViewUtil.getView( | ||
| viewName, | ||
| view.getViewOriginalText(), | ||
| view.getTableType(), | ||
| view.getParameters(), | ||
|
|
@@ -180,7 +179,7 @@ public void updateViewComment(ConnectorSession session, SchemaTableName viewName | |
| io.trino.plugin.hive.metastore.Table view = metastore.getTable(viewName.getSchemaName(), viewName.getTableName()) | ||
| .orElseThrow(() -> new ViewNotFoundException(viewName)); | ||
|
|
||
| ConnectorViewDefinition definition = TrinoViewUtil.getView(viewName, view.getViewOriginalText(), view.getTableType(), view.getParameters(), view.getOwner()) | ||
| ConnectorViewDefinition definition = TrinoViewUtil.getView(view.getViewOriginalText(), view.getTableType(), view.getParameters(), view.getOwner()) | ||
| .orElseThrow(() -> new ViewNotFoundException(viewName)); | ||
| ConnectorViewDefinition newDefinition = new ConnectorViewDefinition( | ||
| definition.getOriginalSql(), | ||
|
|
@@ -199,7 +198,7 @@ public void updateViewColumnComment(ConnectorSession session, SchemaTableName vi | |
| io.trino.plugin.hive.metastore.Table view = metastore.getTable(viewName.getSchemaName(), viewName.getTableName()) | ||
| .orElseThrow(() -> new ViewNotFoundException(viewName)); | ||
|
|
||
| ConnectorViewDefinition definition = TrinoViewUtil.getView(viewName, view.getViewOriginalText(), view.getTableType(), view.getParameters(), view.getOwner()) | ||
| ConnectorViewDefinition definition = TrinoViewUtil.getView(view.getViewOriginalText(), view.getTableType(), view.getParameters(), view.getOwner()) | ||
| .orElseThrow(() -> new ViewNotFoundException(viewName)); | ||
| ConnectorViewDefinition newDefinition = new ConnectorViewDefinition( | ||
| definition.getOriginalSql(), | ||
|
|
||
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.
Do we have a test verifying that COMMENT ON VIEW doesn't work on an MV ?
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.
idk. note that i am not changing this.
toConnectorViewDefinition(...).orElseThrowon next line throws for anything that's not a view