Skip to content

Commit

Permalink
[#5545] fix(doris-catalog): Fix the problem that we can't set Doris t…
Browse files Browse the repository at this point in the history
…able properties. (#6208)

### What changes were proposed in this pull request?

Modify table properties SQL in alter table sentence to support setting
table properties.

### Why are the changes needed?

It's a bug.

Fix: #5545

### Does this PR introduce _any_ user-facing change?

N/A.

### How was this patch tested?

IT.

Co-authored-by: Qi Yu <[email protected]>
  • Loading branch information
github-actions[bot] and yuqi1129 authored Jan 13, 2025
1 parent c731d27 commit 1db049e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,6 @@ protected String generateAlterTableSql(
alterSql.add("MODIFY COMMENT \"" + newComment + "\"");
}

if (!setProperties.isEmpty()) {
alterSql.add(generateTableProperties(setProperties));
}

if (CollectionUtils.isEmpty(alterSql)) {
return "";
}
Expand Down Expand Up @@ -602,11 +598,14 @@ private String updateColumnNullabilityDefinition(
}

private String generateTableProperties(List<TableChange.SetProperty> setProperties) {
return setProperties.stream()
.map(
setProperty ->
String.format("\"%s\" = \"%s\"", setProperty.getProperty(), setProperty.getValue()))
.collect(Collectors.joining(",\n"));
String properties =
setProperties.stream()
.map(
setProperty ->
String.format(
"\"%s\" = \"%s\"", setProperty.getProperty(), setProperty.getValue()))
.collect(Collectors.joining(",\n"));
return "set (" + properties + ")";
}

private String updateColumnCommentFieldDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,16 @@ void testAlterDorisTable() {
.pollInterval(WAIT_INTERVAL_IN_SECONDS, TimeUnit.SECONDS)
.untilAsserted(
() -> assertEquals(4, tableCatalog.loadTable(tableIdentifier).columns().length));

// set property
tableCatalog.alterTable(tableIdentifier, TableChange.setProperty("in_memory", "true"));
Awaitility.await()
.atMost(MAX_WAIT_IN_SECONDS, TimeUnit.SECONDS)
.pollInterval(WAIT_INTERVAL_IN_SECONDS, TimeUnit.SECONDS)
.untilAsserted(
() ->
assertEquals(
"true", tableCatalog.loadTable(tableIdentifier).properties().get("in_memory")));
}

@Test
Expand Down

0 comments on commit 1db049e

Please sign in to comment.