@@ -1290,6 +1290,76 @@ Y_UNIT_TEST_SUITE(KqpConstraints) {
1290
1290
1291
1291
}
1292
1292
1293
+ Y_UNIT_TEST (DefaultAndIndexesTestDefaultColumnNotIncludedInIndex) {
1294
+ NKikimrConfig::TAppConfig appConfig;
1295
+ TKikimrRunner kikimr (TKikimrSettings ().SetPQConfig (DefaultPQConfig ()).SetAppConfig (appConfig));
1296
+
1297
+ auto db = kikimr.GetTableClient ();
1298
+ auto session = db.CreateSession ().GetValueSync ().GetSession ();
1299
+
1300
+ {
1301
+ auto query = R"(
1302
+ --!syntax_v1
1303
+ CREATE TABLE test (
1304
+ A Int64 NOT NULL,
1305
+ B Int64,
1306
+ Created Int32 DEFAULT 1,
1307
+ Deleted Int32 DEFAULT 0,
1308
+ PRIMARY KEY (A ),
1309
+ INDEX testIndex GLOBAL ON (B, A)
1310
+ )
1311
+ )" ;
1312
+
1313
+ auto result = session.ExecuteSchemeQuery (query).GetValueSync ();
1314
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::SUCCESS,
1315
+ result.GetIssues ().ToString ());
1316
+ }
1317
+
1318
+ auto fQuery = [&](TString query) -> TString {
1319
+ NYdb::NTable::TExecDataQuerySettings execSettings;
1320
+ execSettings.KeepInQueryCache (true );
1321
+ execSettings.CollectQueryStats (ECollectQueryStatsMode::Basic);
1322
+
1323
+ auto result =
1324
+ session
1325
+ .ExecuteDataQuery (query, TTxControl::BeginTx ().CommitTx (),
1326
+ execSettings)
1327
+ .ExtractValueSync ();
1328
+
1329
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::SUCCESS,
1330
+ result.GetIssues ().ToString ());
1331
+ if (result.GetResultSets ().size () > 0 )
1332
+ return NYdb::FormatResultSetYson (result.GetResultSet (0 ));
1333
+ return " " ;
1334
+ };
1335
+
1336
+ fQuery (R"(
1337
+ upsert into test (A, B, Created, Deleted) values (5, 15, 1, 0)
1338
+ )" );
1339
+
1340
+ fQuery (R"(
1341
+ $to_upsert = (
1342
+ select A from
1343
+ `test`
1344
+ where A = 5
1345
+ );
1346
+
1347
+ upsert into `test` (A, Deleted)
1348
+ select A, 10 as Deleted from $to_upsert;
1349
+ )" );
1350
+
1351
+ CompareYson (
1352
+ R"(
1353
+ [
1354
+ [5;[15];[1];[10]]
1355
+ ]
1356
+ )" ,
1357
+ fQuery (R"(
1358
+ SELECT A, B, Created, Deleted FROM `test` ORDER BY A;
1359
+ )" )
1360
+ );
1361
+ }
1362
+
1293
1363
Y_UNIT_TEST (Utf8AndDefault) {
1294
1364
1295
1365
NKikimrConfig::TAppConfig appConfig;
0 commit comments