From bdd4317597d4ed8d4737e2552fb09a2669979690 Mon Sep 17 00:00:00 2001 From: kpavlov00 Date: Wed, 15 May 2024 17:15:26 +0300 Subject: [PATCH] fix ydb: fix ydb oss tests, not-nullable non key columns not allowed f7cec534a542c119534987bae082bf1a585efef5 --- ydb/tests/get_test.cpp | 10 +++++----- ydb/tests/schema_test.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ydb/tests/get_test.cpp b/ydb/tests/get_test.cpp index 417cdb4f4c28..32332178ed83 100644 --- a/ydb/tests/get_test.cpp +++ b/ydb/tests/get_test.cpp @@ -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") @@ -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"}, @@ -112,7 +112,7 @@ UTEST_F_DEATH(TYdbRowGetTestCaseDeathTest, TwiceGet) { auto row = cursor.GetFirstRow(); UASSERT_NO_THROW(row.Get>("nullable_bool")); UEXPECT_DEATH(row.Get>("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"); } diff --git a/ydb/tests/schema_test.cpp b/ydb/tests/schema_test.cpp index 0443e10332aa..b7095a21d81d 100644 --- a/ydb/tests/schema_test.cpp +++ b/ydb/tests/schema_test.cpp @@ -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())); @@ -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);