Skip to content

Commit

Permalink
fix ydb: fix ydb oss tests, not-nullable non key columns not allowed
Browse files Browse the repository at this point in the history
f7cec534a542c119534987bae082bf1a585efef5
  • Loading branch information
kpavlov00 committed May 15, 2024
1 parent 8aa6a8a commit bdd4317
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions ydb/tests/get_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class TYdbRowGetTestCase : public ydb::ClientFixtureBase {

private:
void InitializeTable() {
// At this moment we could not create NOT NULL NON KEY fields
DoCreateTable(
"null_not_null_table",
NYdb::NTable::TTableBuilder()
.AddNonNullableColumn("key", NYdb::EPrimitiveType::Uint32)
.AddNonNullableColumn("non_null_col", NYdb::EPrimitiveType::String)
.AddNullableColumn("nullable_bool", NYdb::EPrimitiveType::Bool)
.AddNullableColumn("nullable_str", NYdb::EPrimitiveType::String)
.SetPrimaryKeyColumn("key")
Expand All @@ -28,11 +28,11 @@ class TYdbRowGetTestCase : public ydb::ClientFixtureBase {
R"(
--!syntax_v1
UPSERT INTO null_not_null_table (
key, non_null_col, nullable_bool, nullable_str
key, nullable_bool, nullable_str
) VALUES (
123, "hello", false, "world"
123, false, "helloworld"
), (
321, "hey", null, "hi"
321, null, "hi"
);
)",
ydb::Query::Name{"FillTable/null_not_null_table"},
Expand Down Expand Up @@ -112,7 +112,7 @@ UTEST_F_DEATH(TYdbRowGetTestCaseDeathTest, TwiceGet) {
auto row = cursor.GetFirstRow();
UASSERT_NO_THROW(row.Get<std::optional<bool>>("nullable_bool"));
UEXPECT_DEATH(row.Get<std::optional<bool>>("nullable_bool"),
"It is allowed to take the value of column only once. Index 2 "
"It is allowed to take the value of column only once. Index 1 "
"is already consumed");
}

Expand Down
6 changes: 4 additions & 2 deletions ydb/tests/schema_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ UTEST_F(YdbSchemaNoPredefinedTables, CreateAndDropTable) {
NYdb::NTable::TTableBuilder{}
.AddNonNullableColumn("key", NYdb::EPrimitiveType::String)
.AddNullableColumn("some_id", NYdb::EPrimitiveType::Uint64)
.AddNonNullableColumn(
"some_money", NYdb::TDecimalType{/*precision=*/22, /*scale=*/9})
.AddNullableColumn("some_money",
NYdb::TDecimalType{/*precision=*/22, /*scale=*/9})
.SetPrimaryKeyColumn("key");
UASSERT_NO_THROW(GetTableClient().CreateTable(kTableName, builder.Build()));

Expand Down Expand Up @@ -75,6 +75,8 @@ UTEST_F(YdbSchemaNoPredefinedTables, CreateAndDropTable) {
const auto& column = columns[2];
EXPECT_EQ(column.Name, "some_money");
NYdb::TTypeParser parser{column.Type};
ASSERT_EQ(parser.GetKind(), NYdb::TTypeParser::ETypeKind::Optional);
parser.OpenOptional();
ASSERT_EQ(parser.GetKind(), NYdb::TTypeParser::ETypeKind::Decimal);
const auto decimal = parser.GetDecimal();
EXPECT_EQ(decimal.Precision, 22);
Expand Down

0 comments on commit bdd4317

Please sign in to comment.