Skip to content

Commit

Permalink
fix null comment in table
Browse files Browse the repository at this point in the history
  • Loading branch information
mchades committed Jan 18, 2024
1 parent b4f4ef6 commit bb8c920
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public TableCreateRequest(
@Nullable Partitioning[] partitioning) {
this.name = name;
this.columns = columns;
this.comment = comment;
this.comment = comment == null ? "" : comment;
this.properties = properties;
this.sortOrders = sortOrders;
this.distribution = distribution;
Expand All @@ -92,6 +92,9 @@ public TableCreateRequest(

@Override
public void validate() throws IllegalArgumentException {
// should never happen
Preconditions.checkArgument(comment != null, "\"comment\" field should not be null");

Preconditions.checkArgument(
StringUtils.isNotBlank(name), "\"name\" field is required and cannot be empty");
Preconditions.checkArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ public void testCreateHiveTable() throws TException, InterruptedException {
assertTableEquals(createdTable, hiveTab);
checkTableReadWrite(hiveTab);

// test null comment
resetSchema();
createdTable =
catalog
.asTableCatalog()
.createTable(nameIdentifier, columns, null, properties, Transforms.EMPTY_TRANSFORM);
org.apache.hadoop.hive.metastore.api.Table hiveTab2 =
hiveClientPool.run(client -> client.getTable(schemaName, tableName));
assertTableEquals(createdTable, hiveTab2);
checkTableReadWrite(hiveTab);
Assertions.assertEquals("", createdTable.comment());

// test null partition
resetSchema();
Table createdTable1 =
Expand Down

0 comments on commit bb8c920

Please sign in to comment.