Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ClassCastException during initial schema check #95

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import tech.ydb.table.settings.PartitioningPolicy;
import tech.ydb.table.settings.PartitioningSettings;
import tech.ydb.table.settings.TtlSettings;
import tech.ydb.table.values.OptionalType;
import tech.ydb.table.values.Type;
import tech.ydb.yoj.databind.schema.Schema;
import tech.ydb.yoj.repository.db.EntitySchema;
import tech.ydb.yoj.repository.db.exception.CreateTableException;
Expand Down Expand Up @@ -283,7 +283,7 @@ private Table describeTableInternal(String path) {
table.getColumns().stream()
.map(c -> {
String columnName = c.getName();
String simpleType = ((OptionalType) c.getType()).getItemType().toPb().getTypeId().name();
String simpleType = safeUnwrapOptional(c.getType()).toPb().getTypeId().name();
boolean isPrimaryKey = table.getPrimaryKeys().contains(columnName);
return new Column(columnName, simpleType, isPrimaryKey);
})
Expand All @@ -297,6 +297,10 @@ private Table describeTableInternal(String path) {
);
}

private Type safeUnwrapOptional(Type type) {
return type.getKind() == Type.Kind.OPTIONAL ? type.unwrapOptional() : type;
}

public void removeTablespace() {
removeTablespace(tablespace);
}
Expand Down