Skip to content

Commit ae4e205

Browse files
committed
Fixed not null columns
1 parent 3b4cd80 commit ae4e205

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

table/src/main/java/tech/ydb/table/description/TableDescription.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static class Builder {
128128
private TableTtl ttlSettings = TableTtl.notSet();
129129
private final List<ChangefeedDescription> changefeeds = new ArrayList<>();
130130

131-
public Builder withStoreType(StoreType storeType) {
131+
public Builder setStoreType(StoreType storeType) {
132132
this.storeType = storeType;
133133
return this;
134134
}

table/src/main/java/tech/ydb/table/impl/BaseSession.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import tech.ydb.table.values.ListValue;
9292
import tech.ydb.table.values.StructValue;
9393
import tech.ydb.table.values.TupleValue;
94+
import tech.ydb.table.values.Type;
9495
import tech.ydb.table.values.Value;
9596
import tech.ydb.table.values.proto.ProtoType;
9697
import tech.ydb.table.values.proto.ProtoValue;
@@ -208,6 +209,9 @@ private static YdbTable.ColumnMeta buildColumnMeta(TableColumn column) {
208209
if (column.getFamily() != null) {
209210
builder.setFamily(column.getFamily());
210211
}
212+
if (column.getType().getKind() != Type.Kind.OPTIONAL) {
213+
builder.setNotNull(true);
214+
}
211215
return builder.build();
212216
}
213217

@@ -739,10 +743,10 @@ private static TableDescription mapDescribeTable(
739743
TableDescription.Builder description = TableDescription.newBuilder();
740744
switch (result.getStoreType()) {
741745
case STORE_TYPE_ROW:
742-
description = description.withStoreType(TableDescription.StoreType.ROWS);
746+
description = description.setStoreType(TableDescription.StoreType.ROWS);
743747
break;
744748
case STORE_TYPE_COLUMN:
745-
description = description.withStoreType(TableDescription.StoreType.COLUMNS);
749+
description = description.setStoreType(TableDescription.StoreType.COLUMNS);
746750
break;
747751
case UNRECOGNIZED:
748752
case STORE_TYPE_UNSPECIFIED:

table/src/test/java/tech/ydb/table/integration/AlterTableTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void alterTableTest() {
7474

7575
TableDescription description = describeResult.getValue();
7676

77+
Assert.assertEquals(TableDescription.StoreType.ROWS, description.getStoreType());
7778
Assert.assertEquals(1, description.getColumnFamilies().size());
7879
Assert.assertEquals(DEFAULT_FAMILY, description.getColumnFamilies().get(0).getName());
7980

table/src/test/java/tech/ydb/table/integration/RenameTablesTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package tech.ydb.table.integration;
22

33
import java.util.Arrays;
4+
45
import org.junit.Assert;
56
import org.junit.ClassRule;
67
import org.junit.Test;
8+
79
import tech.ydb.core.Result;
810
import tech.ydb.core.Status;
9-
1011
import tech.ydb.table.SessionRetryContext;
1112
import tech.ydb.table.description.TableColumn;
1213
import tech.ydb.table.description.TableDescription;
@@ -53,8 +54,8 @@ public class RenameTablesTest {
5354
public void testRenameTables() {
5455
TableDescription tableDescription = TableDescription.newBuilder()
5556
.addNullableColumn("id", PrimitiveType.Uint64)
56-
.addNullableColumn("code", PrimitiveType.Text)
57-
.addNullableColumn("size", PrimitiveType.Float)
57+
.addNonnullColumn("code", PrimitiveType.Text)
58+
.addNonnullColumn("size", PrimitiveType.Float)
5859
.addNullableColumn("created", PrimitiveType.Timestamp)
5960
.addNullableColumn("data", PrimitiveType.Json)
6061
.setPrimaryKey("id")

0 commit comments

Comments
 (0)