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 @@ -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 @@ -47,6 +47,7 @@
import org.apache.iceberg.Snapshot;
import org.apache.iceberg.Table;
import org.apache.iceberg.TableOperations;
import org.apache.iceberg.TableProperties;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
Expand Down Expand Up @@ -236,6 +237,24 @@ public void testCreateTableLikeInFlinkCatalog() throws TableNotExistException {
.containsEntry(FlinkCreateTableOptions.SRC_CATALOG_PROPS_KEY, srcCatalogProps);
}

@TestTemplate
public void testCreateTableWithTableComment() {
// create table with comment
sql("CREATE TABLE tl(id BIGINT) COMMENT 'table comment'");
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "table comment");
}

@TestTemplate
public void testAlterTableModifyTableComment() {
// create table with comment
sql("CREATE TABLE tl(id BIGINT) COMMENT 'table comment'");
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "table comment");

// alter table comment
sql("ALTER TABLE tl SET('comment' = 'new comment')");
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "new comment");
}

@TestTemplate
public void testCreateTableLocation() {
assumeThat(isHadoopCatalog)
Expand Down
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 @@ -48,6 +48,7 @@
import org.apache.iceberg.Snapshot;
import org.apache.iceberg.Table;
import org.apache.iceberg.TableOperations;
import org.apache.iceberg.TableProperties;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
Expand Down Expand Up @@ -243,6 +244,24 @@ public void testCreateTableLikeInFlinkCatalog() throws TableNotExistException {
.containsEntry(FlinkCreateTableOptions.SRC_CATALOG_PROPS_KEY, srcCatalogProps);
}

@TestTemplate
public void testCreateTableWithTableComment() {
// create table with comment
sql("CREATE TABLE tl(id BIGINT) COMMENT 'table comment'");
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "table comment");
}

@TestTemplate
public void testAlterTableModifyTableComment() {
// create table with comment
sql("CREATE TABLE tl(id BIGINT) COMMENT 'table comment'");
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "table comment");

// alter table comment
sql("ALTER TABLE tl SET('comment' = 'new comment')");
assertThat(table("tl").properties()).containsEntry(TableProperties.COMMENT, "new comment");
}

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