Skip to content

Commit c6d4d1b

Browse files
authored
Olap TableStore read/write test (#8858)
1 parent 16a986d commit c6d4d1b

File tree

7 files changed

+53
-17
lines changed

7 files changed

+53
-17
lines changed

.github/config/muted_ya.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ydb/core/keyvalue/ut_trace TKeyValueTracingTest.*
1212
ydb/core/kqp/provider/ut KikimrIcGateway.TestLoadBasicSecretValueFromExternalDataSourceMetadata
1313
ydb/core/kqp/ut/olap KqpOlapBlobsSharing.*
1414
ydb/core/kqp/ut/olap KqpOlapStatistics.StatsUsageWithTTL
15+
ydb/core/kqp/ut/olap KqpOlap.TableSinkWithOlapStore
1516
ydb/core/kqp/ut/pg KqpPg.CreateIndex
1617
ydb/core/kqp/ut/query KqpLimits.QueryReplySize
1718
ydb/core/kqp/ut/query KqpQuery.QueryTimeout

ydb/core/kqp/ut/olap/helpers/local.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ class TLocalHelper: public Tests::NCS::THelper {
2828

2929
void CreateTestOlapTable(TString tableName = "olapTable", TString storeName = "olapStore",
3030
ui32 storeShardsCount = 4, ui32 tableShardsCount = 3) {
31-
CreateOlapTableWithStore(tableName, storeName, storeShardsCount, tableShardsCount);
31+
CreateOlapTablesWithStore({tableName}, storeName, storeShardsCount, tableShardsCount);
3232
}
33+
34+
void CreateTestOlapTables(TVector<TString> tableNames = {"olapTable0", "olapTable1"}, TString storeName = "olapStore",
35+
ui32 storeShardsCount = 4, ui32 tableShardsCount = 3) {
36+
CreateOlapTablesWithStore(tableNames, storeName, storeShardsCount, tableShardsCount);
37+
}
38+
3339
using TBase::TBase;
3440

3541
TLocalHelper(TKikimrRunner& runner)

ydb/core/kqp/ut/olap/helpers/typed_local.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TString TTypedLocalHelper::GetMultiColumnTestTableSchema(ui32 reps) const {
4040
}
4141

4242
void TTypedLocalHelper::CreateMultiColumnOlapTableWithStore(ui32 reps, ui32 storeShardsCount, ui32 tableShardsCount) {
43-
CreateSchemaOlapTableWithStore(GetMultiColumnTestTableSchema(reps), TableName, "olapStore", storeShardsCount, tableShardsCount);
43+
CreateSchemaOlapTablesWithStore(GetMultiColumnTestTableSchema(reps), {TableName}, "olapStore", storeShardsCount, tableShardsCount);
4444
}
4545

4646
void TTypedLocalHelper::ExecuteSchemeQuery(const TString& alterQuery, const NYdb::EStatus expectedStatus /*= EStatus::SUCCESS*/) const {

ydb/core/kqp/ut/olap/helpers/typed_local.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class TTypedLocalHelper: public Tests::NCS::THelper {
112112
void FillPKOnly(const double pkKff = 0, const ui32 numRows = 800000) const;
113113

114114
void CreateTestOlapTable(ui32 storeShardsCount = 4, ui32 tableShardsCount = 3) {
115-
CreateOlapTableWithStore(TableName, StoreName, storeShardsCount, tableShardsCount);
115+
CreateOlapTablesWithStore({TableName}, StoreName, storeShardsCount, tableShardsCount);
116116
}
117117

118118
TString GetMultiColumnTestTableSchema(ui32 reps) const;

ydb/core/kqp/ut/olap/kqp_olap_ut.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,32 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
28832883
CompareYson("[[200u]]", result);
28842884
}
28852885
}
2886+
2887+
Y_UNIT_TEST(TableSinkWithOlapStore) {
2888+
NKikimrConfig::TAppConfig appConfig;
2889+
appConfig.MutableTableServiceConfig()->SetEnableOlapSink(true);
2890+
auto settings = TKikimrSettings()
2891+
.SetAppConfig(appConfig)
2892+
.SetWithSampleTables(false);
2893+
TKikimrRunner kikimr(settings);
2894+
Tests::NCommon::TLoggerInit(kikimr).Initialize();
2895+
2896+
TLocalHelper(kikimr).CreateTestOlapTables();
2897+
2898+
WriteTestData(kikimr, "/Root/olapStore/olapTable0", 0, 1000000, 3, true);
2899+
2900+
2901+
auto client = kikimr.GetQueryClient();
2902+
{
2903+
auto result = client.ExecuteQuery(R"(
2904+
SELECT * FROM `/Root/olapStore/olapTable0` ORDER BY timestamp;
2905+
INSERT INTO `/Root/olapStore/olapTable1` SELECT * FROM `/Root/olapStore/olapTable0`;
2906+
INSERT INTO `/Root/olapStore/olapTable0` SELECT * FROM `/Root/olapStore/olapTable1`;
2907+
SELECT * FROM `/Root/olapStore/olapTable1` ORDER BY timestamp;
2908+
)", NYdb::NQuery::TTxControl::BeginTx().CommitTx()).ExtractValueSync();
2909+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
2910+
}
2911+
}
28862912
}
28872913

28882914
}

ydb/core/testlib/cs_helper.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ TString THelper::GetTestTableSchema() const {
198198
return sb;
199199
}
200200

201-
void THelper::CreateSchemaOlapTableWithStore(const TString tableSchema, TString tableName /*= "olapTable"*/, TString storeName /*= "olapStore"*/, ui32 storeShardsCount /*= 4*/, ui32 tableShardsCount /*= 3*/) {
201+
void THelper::CreateSchemaOlapTablesWithStore(const TString tableSchema, TVector<TString> tableNames /*= "olapTable"*/, TString storeName /*= "olapStore"*/, ui32 storeShardsCount /*= 4*/, ui32 tableShardsCount /*= 3*/) {
202202
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
203203
CreateTestOlapStore(sender, Sprintf(R"(
204204
Name: "%s"
@@ -213,19 +213,21 @@ void THelper::CreateSchemaOlapTableWithStore(const TString tableSchema, TString
213213

214214
const TString shardingColumns = "[\"" + JoinSeq("\",\"", GetShardingColumns()) + "\"]";
215215

216-
TBase::CreateTestOlapTable(sender, storeName, Sprintf(R"(
217-
Name: "%s"
218-
ColumnShardCount: %d
219-
Sharding {
220-
HashSharding {
221-
Function: %s
222-
Columns: %s
223-
}
224-
})", tableName.c_str(), tableShardsCount, ShardingMethod.data(), shardingColumns.c_str()));
216+
for (const TString& tableName : tableNames) {
217+
TBase::CreateTestOlapTable(sender, storeName, Sprintf(R"(
218+
Name: "%s"
219+
ColumnShardCount: %d
220+
Sharding {
221+
HashSharding {
222+
Function: %s
223+
Columns: %s
224+
}
225+
})", tableName.c_str(), tableShardsCount, ShardingMethod.data(), shardingColumns.c_str()));
226+
}
225227
}
226228

227-
void THelper::CreateOlapTableWithStore(TString tableName /*= "olapTable"*/, TString storeName /*= "olapStore"*/, ui32 storeShardsCount /*= 4*/, ui32 tableShardsCount /*= 3*/) {
228-
CreateSchemaOlapTableWithStore(GetTestTableSchema(), tableName, storeName, storeShardsCount, tableShardsCount);
229+
void THelper::CreateOlapTablesWithStore(TVector<TString> tableNames /*= {"olapTable"}*/, TString storeName /*= "olapStore"*/, ui32 storeShardsCount /*= 4*/, ui32 tableShardsCount /*= 3*/) {
230+
CreateSchemaOlapTablesWithStore(GetTestTableSchema(), tableNames, storeName, storeShardsCount, tableShardsCount);
229231
}
230232

231233
// Clickbench table

ydb/core/testlib/cs_helper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ class THelper: public THelperSchemaless {
3232
private:
3333
bool WithSomeNulls_ = false;
3434
protected:
35-
void CreateSchemaOlapTableWithStore(const TString tableSchema, TString tableName = "olapTable", TString storeName = "olapStore",
35+
void CreateSchemaOlapTablesWithStore(const TString tableSchema, TVector<TString> tableName = {"olapTable"}, TString storeName = "olapStore",
3636
ui32 storeShardsCount = 4, ui32 tableShardsCount = 3);
37-
void CreateOlapTableWithStore(TString tableName = "olapTable", TString storeName = "olapStore",
37+
void CreateOlapTablesWithStore(TVector<TString> tableName = {"olapTable"}, TString storeName = "olapStore",
3838
ui32 storeShardsCount = 4, ui32 tableShardsCount = 3);
39+
3940
public:
4041
using TBase::TBase;
4142

0 commit comments

Comments
 (0)