Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -62,6 +62,7 @@
import org.apache.iceberg.Schema;
import org.apache.iceberg.StructLike;
import org.apache.iceberg.Table;
import org.apache.iceberg.TableProperties;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.SupportsNamespaces;
Expand Down Expand Up @@ -450,6 +451,11 @@ void createIcebergTable(ObjectPath tablePath, ResolvedCatalogTable table, boolea
}
}

String comment = table.getComment();
if (comment != null && !comment.isEmpty()) {
properties.put(TableProperties.COMMENT, comment);
}

try {
icebergCatalog.createTable(
toIdentifier(tablePath), icebergSchema, spec, location, properties.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ public void testCreateTableLikeInFlinkCatalog() throws TableNotExistException {
.containsEntry(FlinkCreateTableOptions.SRC_CATALOG_PROPS_KEY, srcCatalogProps);
}

@TestTemplate
public void testCreateTableComment() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would create the following tests:
testCreateTableWithTableComment
testAlterTableModifyTableComment

I'm not sure why the alter parameter is here in this test

// create table with comment
sql("CREATE TABLE tl(id BIGINT) COMMENT 'table comment' WITH ('param'='some value')");
Map<String, String> properties = Maps.newHashMap();
properties.put("comment", "table comment");
properties.put("param", "some value");
assertThat(table("tl").properties()).containsAllEntriesOf(properties);

// update parameter
sql("ALTER TABLE tl SET('param'='new value')");
properties.put("param", "new value");
assertThat(table("tl").properties()).containsAllEntriesOf(properties);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertThat(table("tl").properties()).containsAllEntriesOf(properties);
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "table comment");

And then we don't need the extra Map


// alter table comment
sql("ALTER TABLE tl SET('comment' = 'new comment')");
properties.put("comment", "new comment");
assertThat(table("tl").properties()).containsAllEntriesOf(properties);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above

}

@TestTemplate
public void testCreateTableLocation() {
assumeThat(isHadoopCatalog)
Expand Down