aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcherednik <dcherednik@ydb.tech>2022-08-19 15:03:51 +0300
committerdcherednik <dcherednik@ydb.tech>2022-08-19 15:03:51 +0300
commitab9bc5ca72f57e972d0927aae30fcff37f1d5f7b (patch)
tree66e5712aa3fb2cd9a2bc26d9839822e00a391a38
parentad2a1b622d2bf6cf025982846153d9c4c791af2c (diff)
downloadydb-ab9bc5ca72f57e972d0927aae30fcff37f1d5f7b.tar.gz
Remove duplicate ut.
-rw-r--r--ydb/core/kqp/ut/kqp_indexes_ut.cpp917
1 files changed, 0 insertions, 917 deletions
diff --git a/ydb/core/kqp/ut/kqp_indexes_ut.cpp b/ydb/core/kqp/ut/kqp_indexes_ut.cpp
index d98c9f179e..3cf29c8044 100644
--- a/ydb/core/kqp/ut/kqp_indexes_ut.cpp
+++ b/ydb/core/kqp/ut/kqp_indexes_ut.cpp
@@ -392,684 +392,6 @@ Y_UNIT_TEST_SUITE(KqpIndexes) {
}
}
- Y_UNIT_TEST_QUAD(DataColumnUpsertMixedSemantic, WithMvcc, UseNewEngine) {
- auto setting = NKikimrKqp::TKqpSetting();
- auto serverSettings = TKikimrSettings()
- .SetEnableMvcc(WithMvcc)
- .SetEnableMvccSnapshotReads(WithMvcc)
- .SetKqpSettings({setting});
- TKikimrRunner kikimr(serverSettings);
- auto db = kikimr.GetTableClient();
- auto session = db.CreateSession().GetValueSync().GetSession();
- CreateSampleTablesWithIndex(session);
-
- // Just check table prepared
- {
- const auto yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Upsert using pk and some other column. Index will be read from table value from user input.
- // For the first row - insert semantic, the pk absent in the table
- // for the second row - update semantic, the pk found
- // This test checks the implementation has correct handle not exact semantic for table lookup
- // (the lenth of lookup result is not equal to the lengh of the user input)
- {
- const TString query1(Q1_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Value, ExtPayload) VALUES
- ("Primary0", "Value0_", "Something"),
- ("Primary1", "Value1_", "Something");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary0"];["Value0_"]];[["Secondary1"];["Primary1"];["Value1_"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
- }
-
- Y_UNIT_TEST_QUAD(DataColumnWriteNull, WithMvcc, UseNewEngine) {
- auto setting = NKikimrKqp::TKqpSetting();
- auto serverSettings = TKikimrSettings()
- .SetEnableMvcc(WithMvcc)
- .SetEnableMvccSnapshotReads(WithMvcc)
- .SetKqpSettings({setting});
- TKikimrRunner kikimr(serverSettings);
- auto db = kikimr.GetTableClient();
- auto session = db.CreateSession().GetValueSync().GetSession();
- CreateSampleTablesWithIndex(session);
-
- // Just check table prepared
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Upsert using pk and some other column. Index will be read from table value from user input.
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Value, ExtPayload) VALUES
- ("Primary1", NULL, "Something");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];#]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
- // Upsert using pk and some other column. But pass null as input.
-
- {
-
- auto param = db.GetParamsBuilder()
- .AddParam("$rows")
- .EmptyList(
- TTypeBuilder()
- .BeginStruct()
- .AddMember("Key").BeginOptional().Primitive(EPrimitiveType::String).EndOptional()
- .AddMember("Value").BeginOptional().Primitive(EPrimitiveType::String).EndOptional()
- .AddMember("ExtPayload").BeginOptional().Primitive(EPrimitiveType::String).EndOptional()
- .EndStruct()
- .Build()
- )
- .Build()
- .Build();
-
- const TString query1(Q1_(R"(
- DECLARE $rows AS List<Struct<
- Key : String?,
- Value : String?,
- ExtPayload : String?
- >>;
- UPSERT INTO `/Root/SecondaryWithDataColumns`
- SELECT * FROM AS_TABLE($rows);
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), param)
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];#]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
- }
-
-
- Y_UNIT_TEST_QUAD(DataColumnWrite, WithMvcc, UseNewEngine) {
- auto setting = NKikimrKqp::TKqpSetting();
- auto serverSettings = TKikimrSettings()
- .SetEnableMvcc(WithMvcc)
- .SetEnableMvccSnapshotReads(WithMvcc)
- .SetKqpSettings({setting});
- TKikimrRunner kikimr(serverSettings);
- auto db = kikimr.GetTableClient();
- auto session = db.CreateSession().GetValueSync().GetSession();
- CreateSampleTablesWithIndex(session);
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Upsert using previous inserved pk and fk, check data column realy updated
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Index2, Value) VALUES
- ("Primary1", "Secondary1", "Value1_1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1_1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Upsert using previous inserved pk but without fk, check data column still realy updated
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Value) VALUES
- ("Primary1", "Value1_2");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1_2"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Upsert using new pk without fk
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Value) VALUES
- ("Primary2", "Value2_1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2_1"]];[["Secondary1"];["Primary1"];["Value1_2"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Upsert using pk, fk, and some other column. Data column in index must have old value
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Index2, ExtPayload) VALUES
- ("Primary1", "Secondary1", "Something");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2_1"]];[["Secondary1"];["Primary1"];["Value1_2"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Replace row
- {
- const TString query1(Q_(R"(
- REPLACE INTO `/Root/SecondaryWithDataColumns` (Key, Index2, Value) VALUES
- ("Primary1", "Secondary1", "Value1_3");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2_1"]];[["Secondary1"];["Primary1"];["Value1_3"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Replace row but no specify data column
- {
- const TString query1(Q_(R"(
- REPLACE INTO `/Root/SecondaryWithDataColumns` (Key, Index2) VALUES
- ("Primary1", "Secondary1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2_1"]];[["Secondary1"];["Primary1"];#]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Replace row specify data column but no index column
- {
- const TString query1(Q_(R"(
- REPLACE INTO `/Root/SecondaryWithDataColumns` (Key, Value) VALUES
- ("Primary2", "Value2_3");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2_3"]];[["Secondary1"];["Primary1"];#]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Replace just by pk
- {
- const TString query1(Q_(R"(
- REPLACE INTO `/Root/SecondaryWithDataColumns` (Key) VALUES
- ("Primary2");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];#];[["Secondary1"];["Primary1"];#]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Delete
- {
- const TString query1(Q_(R"(
- DELETE FROM `/Root/SecondaryWithDataColumns` ON (Key) VALUES
- ("Primary2"), ("Primary1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = "";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Insert new row in empty table
- {
- const TString query1(Q_(R"(
- INSERT INTO `/Root/SecondaryWithDataColumns` (Key, Index2, Value) VALUES
- ("Primary1", "Secondary1", "Value1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Insert row with same pk
- {
- const TString query1(R"(
- INSERT INTO `/Root/SecondaryWithDataColumns` (Key, Index2, Value) VALUES
- ("Primary1", "Secondary1", "Value1_1");
- )");
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(!result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::PRECONDITION_FAILED);
-
- }
-
- // Index table has not been changed
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[["Secondary1"];["Primary1"];["Value1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Insert new row but no specify index column
- {
- const TString query1(Q_(R"(
- INSERT INTO `/Root/SecondaryWithDataColumns` (Key, Value) VALUES
- ("Primary2", "Value2");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1"];["Primary1"];["Value1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Update on
- {
- const TString query1(Q_(R"(
- UPDATE `/Root/SecondaryWithDataColumns` ON (Key, Index2, Value) VALUES
- ("NonExistPrimary", "Secondary1_1", "Value1_1"),
- ("Primary1", "Secondary1_1", "Value1_1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
-
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1_1"];["Primary1"];["Value1_1"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- {
-
- const TString query1(Q_(R"(
- UPDATE `/Root/SecondaryWithDataColumns` ON (Key, Value) VALUES
- ("Primary1", "Value1_2");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
-
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1_1"];["Primary1"];["Value1_2"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- {
-
- const TString query1(Q_(R"(
- UPDATE `/Root/SecondaryWithDataColumns` ON (Key, Index2, ExtPayload) VALUES
- ("Primary1", "Secondary1_1", "Something");
- )"));
-
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
-
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1_1"];["Primary1"];["Value1_2"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Update where - update data column
- {
- const TString query1(Q_(R"(
- UPDATE `/Root/SecondaryWithDataColumns` SET Value = "Value1_3"
- WHERE Key = "Primary1";
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
-
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1_1"];["Primary1"];["Value1_3"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Update were - do not touch index
- {
- const TString query1(Q_(R"(
- UPDATE `/Root/SecondaryWithDataColumns` SET ExtPayload = "Something2"
- WHERE Key = "Primary1";
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
-
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1_1"];["Primary1"];["Value1_3"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- // Update wete - update index column
- {
- const TString query1(Q_(R"(
- UPDATE `/Root/SecondaryWithDataColumns` SET Index2 = "Secondary1_2"
- WHERE Key = "Primary1";
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
-
- }
-
- {
- const auto& yson = ReadTablePartToYson(session, "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- const TString expected = R"([[#;["Primary2"];["Value2"]];[["Secondary1_2"];["Primary1"];["Value1_3"]]])";
- UNIT_ASSERT_VALUES_EQUAL(yson, expected);
- }
-
- }
-
- Y_UNIT_TEST_QUAD(DataColumnSelect, WithMvcc, UseNewEngine) {
- auto setting = NKikimrKqp::TKqpSetting();
- auto serverSettings = TKikimrSettings()
- .SetEnableMvcc(WithMvcc)
- .SetEnableMvccSnapshotReads(WithMvcc)
- .SetKqpSettings({setting});
- TKikimrRunner kikimr(serverSettings);
- auto db = kikimr.GetTableClient();
- auto session = db.CreateSession().GetValueSync().GetSession();
- CreateSampleTablesWithIndex(session);
-
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryWithDataColumns` (Key, Index2, Value) VALUES
- ("p2", "s2", "2");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
- {
- const TString query1(Q_(R"(
- UPSERT INTO `/Root/SecondaryKeys` (Key, Fk, Value) VALUES
- (1, 111, "Secondary1");
- )"));
-
- auto result = session.ExecuteDataQuery(
- query1,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- }
-
-
- {
- NYdb::NTable::TExecDataQuerySettings execSettings;
- execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic);
- const TString query(Q1_(R"(
- SELECT Value FROM `/Root/SecondaryWithDataColumns` VIEW Index WHERE Index2 = 'Secondary1';
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(),
- execSettings)
- .ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Value1\"]]]");
-
- auto& stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), 1);
-
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access().size(), 1);
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).name(), "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).reads().rows(), 1);
-
- }
-
- {
- NYdb::NTable::TExecDataQuerySettings execSettings;
- execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic);
- const TString query = Q1_(R"(
- SELECT Value FROM `/Root/SecondaryWithDataColumns` VIEW Index WHERE Index2 IN ('Secondary1');
- )");
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(),
- execSettings)
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Value1\"]]]");
-
- auto& stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());
-
- UNIT_ASSERT_VALUES_EQUAL_C(stats.query_phases().size(), 1, stats.DebugString());
-
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access().size(), 1);
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).name(), "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).reads().rows(), 1);
- }
-
- {
- NYdb::NTable::TExecDataQuerySettings execSettings;
- execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic);
-
- const TString query = Q1_(R"(
- SELECT t2.Value FROM `/Root/SecondaryKeys` as t1
- INNER JOIN `/Root/SecondaryWithDataColumns` VIEW Index as t2 ON t2.Index2 = t1.Value;
- )");
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(),
- execSettings)
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)),
- "[[[\"Value1\"]]]");
-
- auto& stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());
-
- int phaseCount = 3; // In mvcc case we don't acquire locks, so that we skip locks check and cleanup
- if (WithMvcc && !UseNewEngine) {
- phaseCount--;
- }
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), phaseCount);
-
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access().size(), 1);
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).name(), "/Root/SecondaryKeys");
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).reads().rows(), 5);
-
- int idx = UseNewEngine ? 2 : 1;
- UNIT_ASSERT_VALUES_EQUAL_C(stats.query_phases(idx).table_access().size(), 1, stats.DebugString());
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).name(), "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).reads().rows(), 1);
- }
-
- {
- NYdb::NTable::TExecDataQuerySettings execSettings;
- execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic);
-
- const TString query = Q1_(R"(
- SELECT t2.Value FROM `/Root/SecondaryWithDataColumns` VIEW Index as t1
- INNER JOIN `/Root/KeyValue2` as t2 ON t2.Key = t1.Value WHERE t1.Index2 = "s2";
- )");
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(),
- execSettings)
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)),
- "[[[\"Two\"]]]");
-
- auto& stats = NYdb::TProtoAccessor::GetProto(*result.GetStats());
-
- int phaseCount = 3; // In mvcc case we don't acquire locks, so that we skip locks check and cleanup
- if (WithMvcc && !UseNewEngine) {
- phaseCount--;
- }
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases().size(), phaseCount);
-
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access().size(), 1);
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).name(), "/Root/SecondaryWithDataColumns/Index/indexImplTable");
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(0).table_access(0).reads().rows(), 1);
-
- int idx = phaseCount - 1;
- if (!WithMvcc && !UseNewEngine) {
- idx--;
- }
- UNIT_ASSERT_VALUES_EQUAL_C(stats.query_phases(idx).table_access().size(), 1, stats.DebugString());
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).name(), "/Root/KeyValue2");
- UNIT_ASSERT_VALUES_EQUAL(stats.query_phases(idx).table_access(0).reads().rows(), 1);
- }
- }
-
-
Y_UNIT_TEST_QUAD(SelectConcurentTX, WithMvcc, UseNewEngine) {
auto setting = NKikimrKqp::TKqpSetting();
auto serverSettings = TKikimrSettings()
@@ -2495,208 +1817,6 @@ Y_UNIT_TEST_SUITE(KqpIndexes) {
}
}
- Y_UNIT_TEST_QUAD(SecondaryIndexSelect, WithMvcc, UseNewEngine) {
- auto setting = NKikimrKqp::TKqpSetting();
- auto serverSettings = TKikimrSettings()
- .SetEnableMvcc(WithMvcc)
- .SetEnableMvccSnapshotReads(WithMvcc)
- .SetKqpSettings({setting});
- TKikimrRunner kikimr(serverSettings);
- auto db = kikimr.GetTableClient();
- auto session = db.CreateSession().GetValueSync().GetSession();
- CreateSampleTablesWithIndex(session);
-
- {
- const TString query(Q1_(R"(
- SELECT Key FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[2]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Key FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk > 1 LIMIT 1;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[2]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Value FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Payload2\"]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Value FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk > 1 LIMIT 1;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Payload2\"]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Key FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2 AND Key = 2;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[2]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Value FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2 AND Key = 2;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Payload2\"]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Value FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2 AND Value = "Payload2";
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Payload2\"]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Key FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2 AND Value = "Payload2";
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[2]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Key, Fk, Value FROM `/Root/SecondaryKeys` VIEW Index WHERE Fk = 2 AND Value = "Payload2" ORDER BY Fk, Key;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[2];[2];[\"Payload2\"]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Value FROM `/Root/SecondaryKeys` VIEW Index WHERE Key = 2;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
-
- if (UseNewEngine) {
- UNIT_ASSERT_C(HasIssue(result.GetIssues(), NYql::TIssuesIds::KIKIMR_WRONG_INDEX_USAGE,
- [](const NYql::TIssue& issue) {
- return issue.Message.Contains("Given predicate is not suitable for used index: Index");
- }), result.GetIssues().ToString());
- } else {
- UNIT_ASSERT_C(HasIssue(result.GetIssues(), NYql::TIssuesIds::KIKIMR_WRONG_INDEX_USAGE,
- [](const NYql::TIssue& issue) {
- return issue.Message.Contains("Given predicate is not suitable for used index");
- }), result.GetIssues().ToString());
- }
-
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Payload2\"]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Fk FROM `/Root/SecondaryKeys` VIEW Index WHERE Key = 2;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
- if (UseNewEngine) {
- UNIT_ASSERT_C(HasIssue(result.GetIssues(), NYql::TIssuesIds::KIKIMR_WRONG_INDEX_USAGE,
- [](const NYql::TIssue& issue) {
- return issue.Message.Contains("Given predicate is not suitable for used index: Index");
- }), result.GetIssues().ToString());
- } else {
- UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
- }
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[2]]]");
- }
-
- {
- const TString query(Q1_(R"(
- SELECT Value, Key FROM `/Root/SecondaryKeys` VIEW Index WHERE Key > 2 ORDER BY Key DESC;
- )"));
-
- auto result = session.ExecuteDataQuery(
- query,
- TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
- .ExtractValueSync();
-
- UNIT_ASSERT(result.IsSuccess());
- UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[\"Payload7\"];[7]];[[\"Payload5\"];[5]]]");
-
- auto result2 = session.ExplainDataQuery(query)
- .ExtractValueSync();
-
-
- UNIT_ASSERT(result2.IsSuccess());
-
- // TODO: Enable after KIKIMR-10368
- //UNIT_ASSERT_C(result2.GetAst().Contains("'\"Reverse\" (Bool '\"true\")"), result2.GetAst());
- //UNIT_ASSERT_C(result2.GetAst().Contains("'\"ItemsLimit\""), result2.GetAst());
- }
- }
-
Y_UNIT_TEST_QUAD(SecondaryIndexOrderBy, WithMvcc, UseNewEngine) {
auto setting = NKikimrKqp::TKqpSetting();
auto serverSettings = TKikimrSettings()
@@ -4571,43 +3691,6 @@ R"([[#;#;["Primary1"];[41u]];[["Secondary2"];[2u];["Primary2"];[42u]];[["Seconda
}
}
- Y_UNIT_TEST_QUAD(DuplicateUpsert, WithMvcc, UseNewEngine) {
- auto setting = NKikimrKqp::TKqpSetting();
- auto serverSettings = TKikimrSettings()
- .SetEnableMvcc(WithMvcc)
- .SetEnableMvccSnapshotReads(WithMvcc)
- .SetKqpSettings({setting});
- TKikimrRunner kikimr(serverSettings);
- auto db = kikimr.GetTableClient();
- auto session = db.CreateSession().GetValueSync().GetSession();
-
- auto tableBuilder = db.GetTableBuilder();
- tableBuilder
- .AddNullableColumn("Key", EPrimitiveType::String)
- .AddNullableColumn("Index2", EPrimitiveType::String)
- .AddNullableColumn("Value", EPrimitiveType::String);
- tableBuilder.SetPrimaryKeyColumns(TVector<TString>{"Key"});
- tableBuilder.AddSecondaryIndex("Index", TVector<TString>{"Index2"});
- auto result = session.CreateTable("/Root/TestTable", tableBuilder.Build()).ExtractValueSync();
- UNIT_ASSERT_VALUES_EQUAL(result.IsTransportError(), false);
- UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS);
-
- {
- const TString query(Q_(R"(
- UPSERT INTO `/Root/TestTable` (Key, Index2, Value) VALUES
- ("Primary1", "Secondary1", "Value1"),
- ("Primary1", "Secondary2", "Value2"),
- ("Primary1", "Secondary3", "Value3");
- )"));
-
- auto result = session.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx()).ExtractValueSync();
- UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
-
- CompareYson(R"([[["Secondary3"];["Primary1"]]])",
- ReadTablePartToYson(session, "/Root/TestTable/Index/indexImplTable"));
- }
- }
-
Y_UNIT_TEST_QUAD(DuplicateUpsertInterleave, WithMvcc, UseNewEngine) {
auto setting = NKikimrKqp::TKqpSetting();
auto serverSettings = TKikimrSettings()