Skip to content

Commit

Permalink
Add SystemSecurityMetadata interface method for column type change
Browse files Browse the repository at this point in the history
  • Loading branch information
oskar-szwajkowski authored and losipiuk committed Feb 2, 2024
1 parent 4b662f3 commit fc020a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ public void columnRenamed(Session session, CatalogSchemaTableName table, String
@Override
public void columnDropped(Session session, CatalogSchemaTableName table, String column) {}

@Override
public void columnTypeChanged(Session session, CatalogSchemaTableName table, String column, String oldType, String newType) {}

private static TrinoException notSupportedException(String catalogName)
{
return new TrinoException(NOT_SUPPORTED, "Catalog does not support permission management: " + catalogName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,18 @@ public void dropField(Session session, TableHandle tableHandle, ColumnHandle col
public void setColumnType(Session session, TableHandle tableHandle, ColumnHandle column, Type type)
{
CatalogHandle catalogHandle = tableHandle.getCatalogHandle();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle.getCatalogName());
ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle);
ColumnMetadata columnMetadata = getColumnMetadata(session, tableHandle, column);
metadata.setColumnType(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column, type);
if (catalogMetadata.getSecurityManagement() == SYSTEM) {
systemSecurityMetadata.columnTypeChanged(
session,
getTableName(session, tableHandle),
columnMetadata.getName(),
columnMetadata.getType().getDisplayName(),
type.getDisplayName());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,9 @@ public interface SystemSecurityMetadata
* A column was dropped
*/
void columnDropped(Session session, CatalogSchemaTableName table, String column);

/**
* Column type was changed
*/
void columnTypeChanged(Session session, CatalogSchemaTableName table, String column, String oldType, String newType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,7 @@ public void columnDropped(Session session, CatalogSchemaTableName table, String
{
throw new UnsupportedOperationException();
}

@Override
public void columnTypeChanged(Session session, CatalogSchemaTableName table, String column, String oldType, String newType) {}
}

0 comments on commit fc020a4

Please sign in to comment.