Skip to content

Commit

Permalink
Merge branch 'main' into feat-5192-2
Browse files Browse the repository at this point in the history
  • Loading branch information
hdygxsj authored Jan 13, 2025
2 parents 8ba1b94 + 7de40b8 commit 47cde44
Show file tree
Hide file tree
Showing 36 changed files with 1,391 additions and 555 deletions.
8 changes: 0 additions & 8 deletions NOTICE.bin
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ zlib in pure Java, which can be obtained at:
* HOMEPAGE:
* http://www.jcraft.com/jzlib/

This product optionally depends on 'Protocol Buffers', Google's data
interchange format, which can be obtained at:

* LICENSE:
* license/LICENSE.protobuf.txt (New BSD License)
* HOMEPAGE:
* http://code.google.com/p/protobuf/

This product optionally depends on 'SLF4J', a simple logging facade for Java,
which can be obtained at:

Expand Down
14 changes: 3 additions & 11 deletions NOTICE.rest
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Dropwizard Hadoop Metrics
Copyright 2016 Josh Elser

AWS EventStream for Java
Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Apache Gravitino (incubating)
Copyright 2024 The Apache Software Foundation
Expand Down Expand Up @@ -488,7 +488,7 @@ The Apache Software Foundation (https://www.apache.org/).
This product includes software developed by
Joda.org (https://www.joda.org/).

Kerby-kerb Admin
Kerby-kerb Admin
Copyright 2014-2022 The Apache Software Foundation

Kerby-kerb core
Expand Down Expand Up @@ -524,7 +524,7 @@ Copyright 2014-2022 The Apache Software Foundation
Kerby PKIX Project
Copyright 2014-2022 The Apache Software Foundation

Kerby Util
Kerby Util
Copyright 2014-2022 The Apache Software Foundation

Kerby XDR Project
Expand Down Expand Up @@ -605,14 +605,6 @@ zlib in pure Java, which can be obtained at:
* HOMEPAGE:
* http://www.jcraft.com/jzlib/

This product optionally depends on 'Protocol Buffers', Google's data
interchange format, which can be obtained at:

* LICENSE:
* license/LICENSE.protobuf.txt (New BSD License)
* HOMEPAGE:
* http://code.google.com/p/protobuf/

This product optionally depends on 'SLF4J', a simple logging facade for Java,
which can be obtained at:

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ protected String generateCreateTableSql(
}
}

validateIndexes(indexes, columns);
appendIndexesSql(indexes, sqlBuilder);

sqlBuilder.append("\n)");
Expand Down Expand Up @@ -642,4 +643,33 @@ private StringBuilder appendColumnDefinition(JdbcColumn column, StringBuilder sq
private static String quote(String name) {
return BACK_QUOTE + name + BACK_QUOTE;
}

/**
* Verify the columns in the index.
*
* @param columns jdbc column
* @param indexes table indexes
*/
private static void validateIndexes(Index[] indexes, JdbcColumn[] columns) {
Map<String, JdbcColumn> columnMap =
Arrays.stream(columns).collect(Collectors.toMap(JdbcColumn::name, c -> c));
for (Index index : indexes) {
if (index.type() == Index.IndexType.UNIQUE_KEY) {
// the column in the unique index must be not null
for (String[] colNames : index.fieldNames()) {
JdbcColumn column = columnMap.get(colNames[0]);
Preconditions.checkArgument(
column != null,
"Column %s in the unique index %s does not exist in the table",
colNames[0],
index.name());
Preconditions.checkArgument(
!column.nullable(),
"Column %s in the unique index %s must be a not null column",
colNames[0],
index.name());
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,27 @@ void testCreateTableIndex() {
Assertions.assertEquals(2, table.index().length);
Assertions.assertNotNull(table.index()[0].name());
Assertions.assertNotNull(table.index()[1].name());

Column notNullCol = Column.of("col_6", Types.LongType.get(), "id", true, false, null);
Exception exception =
assertThrows(
IllegalArgumentException.class,
() ->
tableCatalog.createTable(
tableIdent,
new Column[] {notNullCol},
table_comment,
properties,
Transforms.EMPTY_TRANSFORM,
Distributions.NONE,
new SortOrder[0],
new Index[] {
Indexes.of(Index.IndexType.UNIQUE_KEY, null, new String[][] {{"col_6"}}),
}));
Assertions.assertTrue(
exception
.getMessage()
.contains("Column col_6 in the unique index null must be a not null column"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testOperationTable() {
.withName("col_1")
.withType(VARCHAR)
.withComment("test_comment")
.withNullable(true)
.withNullable(false)
.build());
columns.add(
JdbcColumn.builder()
Expand Down Expand Up @@ -573,7 +573,7 @@ public void testCreateAndLoadTable() {
JdbcColumn.builder()
.withName("col_4")
.withType(Types.DateType.get())
.withNullable(true)
.withNullable(false)
.withComment("date")
.withDefaultValue(Column.DEFAULT_VALUE_NOT_SET)
.build());
Expand Down
Loading

0 comments on commit 47cde44

Please sign in to comment.