Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,12 @@ else if (strings.size() != 2) {
return new MaterializedViewFreshness(true);
}

@Override
public void setColumnComment(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, Optional<String> comment)
{
catalog.updateColumnComment(session, ((IcebergTableHandle) tableHandle).getSchemaTableName(), ((IcebergColumnHandle) column).getColumnIdentity(), comment);
}

private Map<String, Optional<TableToken>> getMaterializedViewToken(ConnectorSession session, SchemaTableName name)
{
Map<String, Optional<TableToken>> viewToken = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,6 @@ void createMaterializedView(
Optional<ConnectorMaterializedViewDefinition> getMaterializedView(ConnectorSession session, SchemaTableName schemaViewName);

void renameMaterializedView(ConnectorSession session, SchemaTableName source, SchemaTableName target);

void updateColumnComment(ConnectorSession session, SchemaTableName schemaTableName, ColumnIdentity columnIdentity, Optional<String> comment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,13 @@ private List<String> listNamespaces(ConnectorSession session, Optional<String> n
}
return listNamespaces(session);
}

@Override
public void updateColumnComment(ConnectorSession session, SchemaTableName schemaTableName, ColumnIdentity columnIdentity, Optional<String> comment)
{
metastore.commentColumn(schemaTableName.getSchemaName(), schemaTableName.getTableName(), columnIdentity.getName(), comment);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update the comment both in the metastore and via the Iceberg updateColumnDoc?

If we don't need the metastore's comment set we can move this code up to IcebergMetadata and make it catalog agnostic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I inspired myself in the implementation from the updateTableComment method which does also talk to the metastore.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove both, as it leads to inconsistent state if the icebergTable.updateSchema().updateColumnDoc fails.

let's reconsider with a followup


Table icebergTable = loadTable(session, schemaTableName);
icebergTable.updateSchema().updateColumnDoc(columnIdentity.getName(), comment.orElse(null)).commit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ protected QueryRunner createQueryRunner()
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
switch (connectorBehavior) {
case SUPPORTS_COMMENT_ON_COLUMN:
Comment thread
findinpath marked this conversation as resolved.
Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow-up can you please add tests for CREATE TABLE with column comment?

see

// TODO: comment set when creating a table
// assertUpdate("CREATE TABLE " + tableName + "(a integer COMMENT 'new column comment')");
// assertThat(getColumnComment(tableName, "a")).isEqualTo("new column comment");
// assertUpdate("DROP TABLE " + tableName);

case SUPPORTS_TOPN_PUSHDOWN:
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ protected QueryRunner createQueryRunner()
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
switch (connectorBehavior) {
case SUPPORTS_COMMENT_ON_COLUMN:
case SUPPORTS_TOPN_PUSHDOWN:
return false;

Expand Down