diff options
author | gvit <[email protected]> | 2023-07-13 11:38:17 +0300 |
---|---|---|
committer | gvit <[email protected]> | 2023-07-13 11:38:17 +0300 |
commit | bd63620347abff176fdc0c9bae4919c4d684b29c (patch) | |
tree | 6cf06c4dfe2cfc4a19511fc76f426380f5e08630 | |
parent | 7f994596c9b79105e75062185e097f690c2342b4 (diff) |
add more tests
-rw-r--r-- | ydb/core/tx/datashard/ut_sequence/datashard_ut_sequence.cpp | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/ydb/core/tx/datashard/ut_sequence/datashard_ut_sequence.cpp b/ydb/core/tx/datashard/ut_sequence/datashard_ut_sequence.cpp index f517bc15206..d5de43cc2c7 100644 --- a/ydb/core/tx/datashard/ut_sequence/datashard_ut_sequence.cpp +++ b/ydb/core/tx/datashard/ut_sequence/datashard_ut_sequence.cpp @@ -67,6 +67,82 @@ Y_UNIT_TEST_SUITE(TSequence) { } } + Y_UNIT_TEST(SequencesIndex) { + TPortManager pm; + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnableSequences(true); + TServerSettings serverSettings(pm.GetPort(2134)); + serverSettings.SetDomainName("Root") + .SetUseRealThreads(false) + .SetAppConfig(appConfig); + + Tests::TServer::TPtr server = new TServer(serverSettings); + auto &runtime = *server->GetRuntime(); + auto sender = runtime.AllocateEdgeActor(); + + // runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + // runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.GetAppData().AllowReadTableImmediate = true; + + InitRoot(server, sender); + + CreateShardedTable(server, sender, "/Root", "table-5", + TShardedTableOptions() + .Sequences(true) + .Columns({ + {"key", "Int64", true, false, "default", "myseq"}, + {"value", "Uint32", true, false}, + }) + .Indexes({ + {"by_i1value", {"value"}, {}, NKikimrSchemeOp::EIndexTypeGlobal}, + })); + + { + TString result = KqpSimpleExec(runtime, "UPSERT INTO `/Root/table-5` (value) VALUES (1), (2), (3);"); + UNIT_ASSERT_VALUES_EQUAL(result, "<empty>"); + } + + { + TString result = KqpSimpleExec(runtime, "INSERT INTO `/Root/table-5` (value) VALUES (4), (5), (6);"); + UNIT_ASSERT_VALUES_EQUAL(result, "<empty>"); + } + + { + TString result = KqpSimpleExec(runtime, "REPLACE INTO `/Root/table-5` (value) VALUES (7), (8), (9);"); + UNIT_ASSERT_VALUES_EQUAL(result, "<empty>"); + } + + { + TString result = KqpSimpleExec(runtime, "SELECT * FROM `/Root/table-5`;"); + UNIT_ASSERT_VALUES_EQUAL( + result, + "{ items { int64_value: 1 } items { uint32_value: 1 } }, " + "{ items { int64_value: 2 } items { uint32_value: 2 } }, " + "{ items { int64_value: 3 } items { uint32_value: 3 } }, " + "{ items { int64_value: 4 } items { uint32_value: 4 } }, " + "{ items { int64_value: 5 } items { uint32_value: 5 } }, " + "{ items { int64_value: 6 } items { uint32_value: 6 } }, " + "{ items { int64_value: 7 } items { uint32_value: 7 } }, " + "{ items { int64_value: 8 } items { uint32_value: 8 } }, " + "{ items { int64_value: 9 } items { uint32_value: 9 } }"); + } + + { + TString result = KqpSimpleExec(runtime, "SELECT * FROM `/Root/table-5` view by_i1value;"); + UNIT_ASSERT_VALUES_EQUAL( + result, + "{ items { int64_value: 1 } items { uint32_value: 1 } }, " + "{ items { int64_value: 2 } items { uint32_value: 2 } }, " + "{ items { int64_value: 3 } items { uint32_value: 3 } }, " + "{ items { int64_value: 4 } items { uint32_value: 4 } }, " + "{ items { int64_value: 5 } items { uint32_value: 5 } }, " + "{ items { int64_value: 6 } items { uint32_value: 6 } }, " + "{ items { int64_value: 7 } items { uint32_value: 7 } }, " + "{ items { int64_value: 8 } items { uint32_value: 8 } }, " + "{ items { int64_value: 9 } items { uint32_value: 9 } }"); + } + } + Y_UNIT_TEST(CreateTableWithDefaultFromSequenceFromSelect) { TPortManager pm; NKikimrConfig::TAppConfig appConfig; @@ -216,4 +292,4 @@ Y_UNIT_TEST_SUITE(TSequence) { } // Y_UNIT_TEST_SUITE(TSequence) -}
\ No newline at end of file +} |