From 51e142811b52ee1f7552bc1fde06dcda6f0b5a5c Mon Sep 17 00:00:00 2001 From: vlad-gogov Date: Tue, 12 Nov 2024 11:19:17 +0000 Subject: [PATCH] add test --- ydb/core/kqp/ut/olap/kqp_olap_ut.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp b/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp index ea70ec138922..c1adb088505f 100644 --- a/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp +++ b/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp @@ -2964,6 +2964,33 @@ Y_UNIT_TEST_SUITE(KqpOlap) { UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString()); } } + + Y_UNIT_TEST(ScanFailedSnapshotTooOld) { + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnableOlapSink(true); + appConfig.MutableColumnShardConfig()->SetMaxReadStaleness_ms(100); + auto settings = TKikimrSettings().SetAppConfig(appConfig).SetWithSampleTables(false); + TTestHelper testHelper(settings); + + TTestHelper::TColumnTable cnt; + TVector schema = { + TTestHelper::TColumnSchema().SetName("key").SetType(NScheme::NTypeIds::Int32).SetNullable(false), + TTestHelper::TColumnSchema().SetName("c").SetType(NScheme::NTypeIds::Int32).SetNullable(true) + }; + cnt.SetName("/Root/cnt").SetPrimaryKey({ "key" }).SetSchema(schema); + testHelper.CreateTable(cnt); + + auto client = testHelper.GetKikimr().GetQueryClient(); + auto result = + client + .ExecuteQuery( + TStringBuilder() << "$v = SELECT CAST(COUNT(*) AS INT32) FROM `/Root/cnt`; INSERT INTO `/Root/cnt` (key, c) values(1, $v);", + NYdb::NQuery::TTxControl::BeginTx().CommitTx()) + .GetValueSync(); + UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::BAD_REQUEST); + UNIT_ASSERT_VALUES_EQUAL(result.GetIssues().Size(), 1); + UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "scan failed, reason: cannot build metadata/Snapshot too old"); + } } }