-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add column add/drop/rename events #15225
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 |
|---|---|---|
|
|
@@ -726,6 +726,14 @@ public void renameColumn(Session session, TableHandle tableHandle, ColumnHandle | |
| CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); | ||
| ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); | ||
| metadata.renameColumn(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), source, target.toLowerCase(ENGLISH)); | ||
|
|
||
| CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); | ||
| ColumnMetadata sourceColumnMetadata = getColumnMetadata(session, tableHandle, source); | ||
| if (catalogMetadata.getSecurityManagement() != CONNECTOR) { | ||
| TableMetadata tableMetadata = getTableMetadata(session, tableHandle); | ||
| CatalogSchemaTableName sourceTableName = new CatalogSchemaTableName(catalogHandle.getCatalogName(), tableMetadata.getTable()); | ||
| systemSecurityMetadata.columnRenamed(session, sourceTableName, sourceColumnMetadata.getName(), target); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -734,14 +742,28 @@ public void addColumn(Session session, TableHandle tableHandle, ColumnMetadata c | |
| CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); | ||
| ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); | ||
| metadata.addColumn(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column); | ||
|
|
||
| CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); | ||
| if (catalogMetadata.getSecurityManagement() != CONNECTOR) { | ||
| TableMetadata tableMetadata = getTableMetadata(session, tableHandle); | ||
| CatalogSchemaTableName sourceTableName = new CatalogSchemaTableName(catalogHandle.getCatalogName(), tableMetadata.getTable()); | ||
| systemSecurityMetadata.columnCreated(session, sourceTableName, column.getName()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void dropColumn(Session session, TableHandle tableHandle, ColumnHandle column) | ||
| { | ||
| CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); | ||
| ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); | ||
| CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); | ||
| metadata.dropColumn(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column); | ||
| if (catalogMetadata.getSecurityManagement() != CONNECTOR) { | ||
| String columnName = getColumnMetadata(session, tableHandle, column).getName(); | ||
| TableMetadata tableMetadata = getTableMetadata(session, tableHandle); | ||
| CatalogSchemaTableName sourceTableName = new CatalogSchemaTableName(catalogHandle.getCatalogName(), tableMetadata.getTable()); | ||
| systemSecurityMetadata.columnDropped(session, sourceTableName, columnName); | ||
|
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. this may be problematic from transaction perspective. credits to @losipiuk for thinking about that
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. a bit related, but vice versa, a failure here will cause Trino transaction failure even if the connector applied the changes immediately (many do). This led to #12535, see #12535 (comment) for explanation
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. Notice that problem also exists for other |
||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
@djsstarburst
It seems it doesn't work for some connectors.
For example, with Hive connector,
metadata.dropColumnsets theSemiTransactionalHiveMetastoreintoEXCLUSIVE_OPERATION_BUFFEREDstate and thengetTableMetadatafails