From d6c5ff38afbd7cfb3e9fd463f0907653443b2cd6 Mon Sep 17 00:00:00 2001 From: Alexander Avdonkin Date: Thu, 22 Aug 2024 14:45:03 +0000 Subject: [PATCH 1/2] Added sparsed columns tests for standalone tables --- ydb/core/kqp/ut/olap/helpers/typed_local.h | 2 +- ydb/core/kqp/ut/olap/sparsed_ut.cpp | 56 +++++++++++++++++----- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ydb/core/kqp/ut/olap/helpers/typed_local.h b/ydb/core/kqp/ut/olap/helpers/typed_local.h index a72cef64e33e..0ae2c1a544ad 100644 --- a/ydb/core/kqp/ut/olap/helpers/typed_local.h +++ b/ydb/core/kqp/ut/olap/helpers/typed_local.h @@ -29,7 +29,7 @@ class TTypedLocalHelper: public Tests::NCS::THelper { : TBase(kikimrRunner.GetTestServer()) , TypeName(typeName) , KikimrRunner(kikimrRunner) - , TablePath("/Root/" + storeName + "/" + tableName) + , TablePath(storeName.empty() ? "/Root/" + tableName : "/Root/" + storeName + "/" + tableName) , TableName(tableName) , StoreName(storeName) { SetShardingMethod("HASH_FUNCTION_CONSISTENCY_64"); diff --git a/ydb/core/kqp/ut/olap/sparsed_ut.cpp b/ydb/core/kqp/ut/olap/sparsed_ut.cpp index 88bc081fa357..91e8c9c5c053 100644 --- a/ydb/core/kqp/ut/olap/sparsed_ut.cpp +++ b/ydb/core/kqp/ut/olap/sparsed_ut.cpp @@ -18,10 +18,12 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) { const TKikimrSettings Settings = TKikimrSettings().SetWithSampleTables(false); TKikimrRunner Kikimr; NKikimr::NYDBTest::TControllers::TGuard CSController; + const TString StoreName; public: - TSparsedDataTest() + TSparsedDataTest(const char* storeName) : Kikimr(Settings) , CSController(NKikimr::NYDBTest::TControllers::RegisterCSControllerGuard()) + , StoreName(storeName) { } @@ -30,8 +32,7 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) { auto selectQuery = TString(R"( SELECT count(*) as count, - FROM `/Root/olapStore/olapTable` - )"); + FROM `/Root/)") + (StoreName.empty() ? "" : StoreName + "/") + "olapTable`"; auto tableClient = Kikimr.GetTableClient(); auto rows = ExecuteScanQuery(tableClient, selectQuery); @@ -42,9 +43,9 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) { auto selectQuery = TString(R"( SELECT count(*) as count, - FROM `/Root/olapStore/olapTable` + FROM `/Root/)") + (StoreName.empty() ? "" : StoreName + "/") + R"(olapTable` WHERE field == 'abcde' - )"); + )"; auto tableClient = Kikimr.GetTableClient(); auto rows = ExecuteScanQuery(tableClient, selectQuery); @@ -52,7 +53,7 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) { } void FillCircle(const double shiftKff, const ui32 countExpectation) { - TTypedLocalHelper helper("Utf8", Kikimr); + TTypedLocalHelper helper("Utf8", Kikimr, "olapTable", StoreName); const double frq = 0.9; { NArrow::NConstruction::TStringPoolFiller sPool(1000, 52, "abcde", frq); @@ -98,23 +99,52 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) { CSController->SetOverridePeriodicWakeupActivationPeriod(TDuration::MilliSeconds(100)); Tests::NCommon::TLoggerInit(Kikimr).Initialize(); - TTypedLocalHelper helper("Utf8", Kikimr); - helper.CreateTestOlapTable(); + TTypedLocalHelper helper("Utf8", Kikimr, "olapTable", StoreName); + if (!StoreName.empty()) { + helper.CreateTestOlapTable(); + } else { + auto tableClient = Kikimr.GetTableClient(); + auto session = tableClient.CreateSession().GetValueSync().GetSession(); + + auto query = TStringBuilder() << R"( + --!syntax_v1 + CREATE TABLE `/Root/olapTable` + ( + pk_int int64 NOT NULL, + field )" << "Utf8" << R"(, + ts TimeStamp, + PRIMARY KEY (pk_int) + ) + PARTITION BY HASH(pk_int) + WITH ( + STORE = COLUMN + ))"; + auto result = session.ExecuteSchemeQuery(query).GetValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::SUCCESS, result.GetIssues().ToString()); + } + + TString type = StoreName.empty() ? "TABLE" : "TABLESTORE"; + TString name = StoreName.empty() ? "olapTable" : "olapStore"; FillCircle(0, 10000); - helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/olapStore` (TYPE TABLESTORE) SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`SPARSED`, `DEFAULT_VALUE`=`abcde`);"); + helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/" + name + "`(TYPE " + type + ") SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`SPARSED`, `DEFAULT_VALUE`=`abcde`);"); FillCircle(0.1, 11000); - helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/olapStore` (TYPE TABLESTORE) SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`PLAIN`);"); + helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/" + name + "`(TYPE " + type + ") SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`PLAIN`);"); FillCircle(0.2, 12000); - helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/olapStore` (TYPE TABLESTORE) SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`SPARSED`);"); + helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/" + name + "`(TYPE " + type + ") SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`SPARSED`);"); FillCircle(0.3, 13000); - helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/olapStore` (TYPE TABLESTORE) SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`PLAIN`);"); + helper.ExecuteSchemeQuery("ALTER OBJECT `/Root/" + name + "`(TYPE " + type + ") SET (ACTION=ALTER_COLUMN, NAME=field, `DATA_ACCESSOR_CONSTRUCTOR.CLASS_NAME`=`PLAIN`);"); FillCircle(0.4, 14000); } }; Y_UNIT_TEST(Switching) { - TSparsedDataTest test; + TSparsedDataTest test("olapStore"); + test.Execute(); + } + + Y_UNIT_TEST(SwitchingNoStore) { + TSparsedDataTest test(""); test.Execute(); } } From 5fbe99b1de15a26192e928a1ee0004f3be15fbf8 Mon Sep 17 00:00:00 2001 From: Alexander Avdonkin Date: Thu, 22 Aug 2024 15:29:49 +0000 Subject: [PATCH 2/2] Renamed test name --- ydb/core/kqp/ut/olap/sparsed_ut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ydb/core/kqp/ut/olap/sparsed_ut.cpp b/ydb/core/kqp/ut/olap/sparsed_ut.cpp index 91e8c9c5c053..cc40397496ee 100644 --- a/ydb/core/kqp/ut/olap/sparsed_ut.cpp +++ b/ydb/core/kqp/ut/olap/sparsed_ut.cpp @@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(KqpOlapSparsed) { test.Execute(); } - Y_UNIT_TEST(SwitchingNoStore) { + Y_UNIT_TEST(SwitchingStandalone) { TSparsedDataTest test(""); test.Execute(); }