@@ -3174,7 +3174,7 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
31743174 CompareYson (R"( [[4u]])" , FormatResultSetYson (result.GetResultSet (1 )));
31753175 }
31763176
3177- /* {
3177+ {
31783178 auto result = client.ExecuteQuery (R"(
31793179 DELETE FROM `/Root/ColumnShard` ON SELECT * FROM `/Root/DataShard` WHERE Col1 > 9;
31803180 )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
@@ -3223,7 +3223,127 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
32233223 DELETE FROM `/Root/ColumnShard` WHERE Col2 = "not found";
32243224 )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
32253225 UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
3226- }*/
3226+ }
3227+ }
3228+
3229+ Y_UNIT_TEST_TWIN (TableSink_HtapComplex, withOltpSink) {
3230+ NKikimrConfig::TAppConfig appConfig;
3231+ appConfig.MutableTableServiceConfig ()->SetEnableOlapSink (true );
3232+ appConfig.MutableTableServiceConfig ()->SetEnableOltpSink (withOltpSink);
3233+ appConfig.MutableTableServiceConfig ()->SetEnableHtapTx (true );
3234+ auto settings = TKikimrSettings ()
3235+ .SetAppConfig (appConfig)
3236+ .SetWithSampleTables (false );
3237+ TKikimrRunner kikimr (settings);
3238+ Tests::NCommon::TLoggerInit (kikimr).Initialize ();
3239+
3240+ auto session = kikimr.GetTableClient ().CreateSession ().GetValueSync ().GetSession ();
3241+
3242+ const TString query = R"(
3243+ CREATE TABLE `/Root/ColumnSrc` (
3244+ Col1 Uint64 NOT NULL,
3245+ Col2 String NOT NULL,
3246+ Col3 Int32 NOT NULL,
3247+ PRIMARY KEY (Col1)
3248+ )
3249+ PARTITION BY HASH(Col1)
3250+ WITH (STORE = COLUMN, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10);
3251+
3252+ CREATE TABLE `/Root/RowSrc` (
3253+ Col1 Uint64 NOT NULL,
3254+ Col2 String NOT NULL,
3255+ Col3 Int32 NOT NULL,
3256+ PRIMARY KEY (Col1)
3257+ )
3258+ WITH (UNIFORM_PARTITIONS = 2, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 2);
3259+
3260+ CREATE TABLE `/Root/ColumnDst` (
3261+ Col1 Uint64 NOT NULL,
3262+ Col2 String,
3263+ Col3 Int32,
3264+ PRIMARY KEY (Col1)
3265+ )
3266+ PARTITION BY HASH(Col1)
3267+ WITH (STORE = COLUMN, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10);
3268+
3269+ CREATE TABLE `/Root/RowDst` (
3270+ Col1 Uint64 NOT NULL,
3271+ Col2 String,
3272+ Col3 Int32,
3273+ PRIMARY KEY (Col1)
3274+ )
3275+ WITH (UNIFORM_PARTITIONS = 2, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 2);
3276+ )" ;
3277+
3278+ auto result = session.ExecuteSchemeQuery (query).GetValueSync ();
3279+ UNIT_ASSERT_C (result.GetStatus () == NYdb::EStatus::SUCCESS, result.GetIssues ().ToString ());
3280+
3281+ auto client = kikimr.GetQueryClient ();
3282+
3283+ {
3284+ auto result = client.ExecuteQuery (R"(
3285+ UPSERT INTO `/Root/ColumnSrc` (Col1, Col2, Col3) VALUES
3286+ (1u, "test1", 10), (2u, "test2", 11);
3287+ REPLACE INTO `/Root/ColumnSrc` (Col1, Col2, Col3) VALUES
3288+ (3u, "test3", 12), (4u, "test", 13);
3289+ UPSERT INTO `/Root/RowSrc` (Col1, Col2, Col3) VALUES
3290+ (10u, "test1", 10), (20u, "test2", 11);
3291+ REPLACE INTO `/Root/RowSrc` (Col1, Col2, Col3) VALUES
3292+ (30u, "test3", 12), (40u, "test", 13);
3293+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
3294+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
3295+ }
3296+
3297+ {
3298+ auto result = client.ExecuteQuery (R"(
3299+ $data = SELECT c.Col1 as Col1, c.Col2 As Col2, r.Col3 AS Col3
3300+ FROM `/Root/ColumnSrc`as c
3301+ JOIN `/Root/RowSrc` as r
3302+ ON c.Col1 + 10 = r.Col3;
3303+ UPSERT INTO `/Root/ColumnDst` SELECT * FROM $data;
3304+ REPLACE INTO `/Root/RowDst` SELECT * FROM $data;
3305+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
3306+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
3307+ }
3308+
3309+ {
3310+ auto result = client.ExecuteQuery (R"(
3311+ SELECT COUNT(*) FROM `/Root/ColumnDst`;
3312+ SELECT COUNT(*) FROM `/Root/RowDst`;
3313+ DELETE FROM `/Root/ColumnDst` WHERE 1=1;
3314+ DELETE FROM `/Root/RowDst` WHERE 1=1;
3315+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
3316+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
3317+ CompareYson (R"( [[3u]])" , FormatResultSetYson (result.GetResultSet (0 )));
3318+ CompareYson (R"( [[3u]])" , FormatResultSetYson (result.GetResultSet (1 )));
3319+ }
3320+
3321+ {
3322+ auto result = client.ExecuteQuery (R"(
3323+ $prepare = SELECT *
3324+ FROM `/Root/ColumnSrc`
3325+ WHERE Col2 LIKE '%test%test%';
3326+ $data = SELECT c.Col1 as Col1, c.Col2 As Col2, r.Col3 AS Col3
3327+ FROM `/Root/RowSrc`as c
3328+ LEFT OUTER JOIN $prepare as r
3329+ ON c.Col1 + 10 = r.Col3;
3330+ UPSERT INTO `/Root/ColumnDst` SELECT * FROM $data;
3331+ REPLACE INTO `/Root/RowDst` SELECT * FROM $data;
3332+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
3333+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
3334+ }
3335+
3336+ {
3337+ auto result = client.ExecuteQuery (R"(
3338+ SELECT COUNT(*) FROM `/Root/ColumnDst`;
3339+ SELECT COUNT(*) FROM `/Root/RowDst`;
3340+ DELETE FROM `/Root/ColumnDst` WHERE 1=1;
3341+ DELETE FROM `/Root/RowDst` WHERE 1=1;
3342+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
3343+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
3344+ CompareYson (R"( [[4u]])" , FormatResultSetYson (result.GetResultSet (0 )));
3345+ CompareYson (R"( [[4u]])" , FormatResultSetYson (result.GetResultSet (1 )));
3346+ }
32273347 }
32283348
32293349 Y_UNIT_TEST_TWIN (TableSink_HtapInteractive, withOltpSink) {
0 commit comments