Skip to content

Commit 2ac0aca

Browse files
committed
Add missing defaultValue for ColumnMetadata.Builder
1 parent ed1b468 commit 2ac0aca

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

core/trino-spi/src/main/java/io/trino/spi/connector/ColumnMetadata.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ private Builder(ColumnMetadata columnMetadata)
190190
{
191191
this.name = columnMetadata.getName();
192192
this.type = columnMetadata.getType();
193+
this.defaultValue = columnMetadata.getDefaultValue();
193194
this.nullable = columnMetadata.isNullable();
194195
this.comment = Optional.ofNullable(columnMetadata.getComment());
195196
this.extraInfo = Optional.ofNullable(columnMetadata.getExtraInfo());
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package io.trino.spi.connector;
15+
16+
import com.google.common.collect.ImmutableMap;
17+
import org.junit.jupiter.api.Test;
18+
19+
import java.util.Optional;
20+
21+
import static io.trino.spi.type.IntegerType.INTEGER;
22+
import static org.assertj.core.api.Assertions.assertThat;
23+
24+
class TestColumnMetadata
25+
{
26+
@Test
27+
public void testBuilderFrom()
28+
{
29+
ColumnMetadata originColumnMetadata = ColumnMetadata.builder()
30+
.setName("test_column")
31+
.setType(INTEGER)
32+
.setDefaultValue(Optional.of("1"))
33+
.setNullable(false)
34+
.setComment(Optional.ofNullable("test_comment"))
35+
.setExtraInfo(Optional.of("test_extra_info"))
36+
.setHidden(false)
37+
.setProperties(ImmutableMap.of("test_key", "test_value"))
38+
.build();
39+
40+
ColumnMetadata buildColumnMetadata = ColumnMetadata.builderFrom(originColumnMetadata).build();
41+
42+
assertThat(buildColumnMetadata).isEqualTo(originColumnMetadata);
43+
assertThat(buildColumnMetadata.getDefaultValue()).isEqualTo(originColumnMetadata.getDefaultValue());
44+
assertThat(buildColumnMetadata.getProperties()).isEqualTo(originColumnMetadata.getProperties());
45+
}
46+
}

0 commit comments

Comments
 (0)