Skip to content

Commit

Permalink
Add column comments for Iceberg tables
Browse files Browse the repository at this point in the history
Cherry-pick of trinodb/trino@bc61aca

Co-Authored-By: Yuya Ebihara <yuya.ebihara@starburstdata.com>
  • Loading branch information
ChunxuTang and ebyhr committed Mar 17, 2022
1 parent 1820148 commit 5571650
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle
{
TableIdentifier tableIdentifier = toIcebergTableIdentifier(((IcebergTableHandle) tableHandle).getSchemaTableName());
Table icebergTable = resourceFactory.getCatalog(session).loadTable(tableIdentifier);
icebergTable.updateSchema().addColumn(column.getName(), toIcebergType(column.getType())).commit();
icebergTable.updateSchema().addColumn(column.getName(), toIcebergType(column.getType()), column.getComment()).commit();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle
{
IcebergTableHandle handle = (IcebergTableHandle) tableHandle;
org.apache.iceberg.Table icebergTable = getHiveIcebergTable(metastore, hdfsEnvironment, session, handle.getSchemaTableName());
icebergTable.updateSchema().addColumn(column.getName(), toIcebergType(column.getType())).commit();
icebergTable.updateSchema().addColumn(column.getName(), toIcebergType(column.getType()), column.getComment()).commit();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ public void testColumnComments()
assertQuery(session, "SHOW COLUMNS FROM test_column_comments",
"VALUES ('_bigint', 'bigint', '', 'test column comment')");

assertUpdate("ALTER TABLE test_column_comments ADD COLUMN _varchar VARCHAR COMMENT 'test new column comment'");
assertQuery(
"SHOW COLUMNS FROM test_column_comments",
"VALUES ('_bigint', 'bigint', '', 'test column comment'), ('_varchar', 'varchar', '', 'test new column comment')");

dropTable(session, "test_column_comments");
}

Expand Down

0 comments on commit 5571650

Please sign in to comment.