@@ -1024,10 +1024,11 @@ namespace NTypeAnnImpl {
1024
1024
sourceNameNode = input->ChildPtr(2);
1025
1025
}
1026
1026
1027
- if (!EnsureStructOrOptionalStructType(*rowNode, ctx.Expr)) {
1027
+ bool isOptionalStruct = false;
1028
+ const TStructExprType* structType = nullptr;
1029
+ if (!EnsureStructOrOptionalStructType(*rowNode, isOptionalStruct, structType, ctx.Expr)) {
1028
1030
return IGraphTransformer::TStatus::Error;
1029
1031
}
1030
- const TStructExprType* structType = RemoveAllOptionals(rowNode->GetTypeAnn())->Cast<TStructExprType>();
1031
1032
1032
1033
if (!EnsureAtom(*columnNameNode, ctx.Expr)) {
1033
1034
return IGraphTransformer::TStatus::Error;
@@ -1109,7 +1110,9 @@ namespace NTypeAnnImpl {
1109
1110
return IGraphTransformer::TStatus::Error;
1110
1111
}
1111
1112
1112
- if (!EnsureStructOrOptionalStructType(input->Head(), ctx.Expr)) {
1113
+ bool isOptional = false;
1114
+ const TStructExprType* structType = nullptr;
1115
+ if (!EnsureStructOrOptionalStructType(input->Head(), isOptional, structType, ctx.Expr)) {
1113
1116
return IGraphTransformer::TStatus::Error;
1114
1117
}
1115
1118
@@ -1123,15 +1126,12 @@ namespace NTypeAnnImpl {
1123
1126
return IGraphTransformer::TStatus::Error;
1124
1127
}
1125
1128
1126
- bool isOptional = input->Head().GetTypeAnn()->GetKind() == ETypeAnnotationKind::Optional;
1127
- const TStructExprType& structType = *RemoveAllOptionals(input->Head().GetTypeAnn())->Cast<TStructExprType>();
1128
-
1129
- auto pos = FindOrReportMissingMember(columnNameNode->Content(), input->Pos(), structType, ctx.Expr);
1129
+ auto pos = FindOrReportMissingMember(columnNameNode->Content(), input->Pos(), *structType, ctx.Expr);
1130
1130
if (!pos) {
1131
1131
return IGraphTransformer::TStatus::Error;
1132
1132
}
1133
1133
1134
- const TTypeAnnotationNode* resultType = structType. GetItems()[*pos]->GetItemType();
1134
+ const TTypeAnnotationNode* resultType = structType-> GetItems()[*pos]->GetItemType();
1135
1135
if (isOptional && resultType->GetKind() != ETypeAnnotationKind::Optional && resultType->GetKind() != ETypeAnnotationKind::Null) {
1136
1136
resultType = ctx.Expr.MakeType<TOptionalExprType>(input->GetTypeAnn());
1137
1137
}
@@ -1150,7 +1150,9 @@ namespace NTypeAnnImpl {
1150
1150
return IGraphTransformer::TStatus::Repeat;
1151
1151
}
1152
1152
1153
- if (!EnsureStructOrOptionalStructType(input->Head(), ctx.Expr)) {
1153
+ const TStructExprType* structType = nullptr;
1154
+ bool isStructOptional = false;
1155
+ if (!EnsureStructOrOptionalStructType(input->Head(), isStructOptional, structType, ctx.Expr)) {
1154
1156
return IGraphTransformer::TStatus::Error;
1155
1157
}
1156
1158
@@ -1162,15 +1164,6 @@ namespace NTypeAnnImpl {
1162
1164
return IGraphTransformer::TStatus::Error;
1163
1165
}
1164
1166
1165
- const TStructExprType* structType = nullptr;
1166
- bool isStructOptional = false;
1167
- if (input->Head().GetTypeAnn()->GetKind() == ETypeAnnotationKind::Optional) {
1168
- isStructOptional = true;
1169
- structType = input->Head().GetTypeAnn()->Cast<TOptionalExprType>()->GetItemType()->Cast<TStructExprType>();
1170
- } else {
1171
- structType = input->Head().GetTypeAnn()->Cast<TStructExprType>();
1172
- }
1173
-
1174
1167
auto otherType = input->Child(2)->GetTypeAnn();
1175
1168
const bool isOptional = otherType->IsOptionalOrNull();
1176
1169
auto memberName = input->Child(1)->Content();
@@ -1231,16 +1224,13 @@ namespace NTypeAnnImpl {
1231
1224
}
1232
1225
1233
1226
auto structObj = child->Child(1);
1234
- if (!EnsureStructOrOptionalStructType(*structObj, ctx.Expr)) {
1227
+ bool optional = false;
1228
+ const TStructExprType* structType = nullptr;
1229
+ if (!EnsureStructOrOptionalStructType(*structObj, optional, structType, ctx.Expr)) {
1235
1230
return IGraphTransformer::TStatus::Error;
1236
1231
}
1237
1232
1238
- auto type = structObj->GetTypeAnn();
1239
- const bool optional = type->GetKind() == ETypeAnnotationKind::Optional;
1240
- if (optional) {
1241
- type = type->Cast<TOptionalExprType>()->GetItemType();
1242
- }
1243
- for (auto& field: type->Cast<TStructExprType>()->GetItems()) {
1233
+ for (auto& field: structType->GetItems()) {
1244
1234
auto itemType = field->GetItemType();
1245
1235
if (optional && !itemType->IsOptionalOrNull()) {
1246
1236
itemType = ctx.Expr.MakeType<TOptionalExprType>(itemType);
@@ -1351,7 +1341,9 @@ namespace NTypeAnnImpl {
1351
1341
}
1352
1342
1353
1343
auto structObj = input->Child(0);
1354
- if (!EnsureStructOrOptionalStructType(*structObj, ctx.Expr)) {
1344
+ bool optional = false;
1345
+ const TStructExprType* structExprType = nullptr;
1346
+ if (!EnsureStructOrOptionalStructType(*structObj, optional, structExprType, ctx.Expr)) {
1355
1347
return IGraphTransformer::TStatus::Error;
1356
1348
}
1357
1349
@@ -1360,13 +1352,7 @@ namespace NTypeAnnImpl {
1360
1352
return status;
1361
1353
}
1362
1354
1363
- auto type = structObj->GetTypeAnn();
1364
- const bool optional = type->GetKind() == ETypeAnnotationKind::Optional;
1365
- if (optional) {
1366
- type = type->Cast<TOptionalExprType>()->GetItemType();
1367
- }
1368
1355
TVector<const TItemExprType*> allItems;
1369
- auto structExprType = type->Cast<TStructExprType>();
1370
1356
for (auto& field: structExprType->GetItems()) {
1371
1357
const auto& fieldName = field->GetName();
1372
1358
auto prefixes = input->Child(1);
@@ -1397,7 +1383,9 @@ namespace NTypeAnnImpl {
1397
1383
}
1398
1384
1399
1385
auto structObj = input->Child(0);
1400
- if (!EnsureStructOrOptionalStructType(*structObj, ctx.Expr)) {
1386
+ bool optional = false;
1387
+ const TStructExprType* structExprType = nullptr;
1388
+ if (!EnsureStructOrOptionalStructType(*structObj, optional, structExprType, ctx.Expr)) {
1401
1389
return IGraphTransformer::TStatus::Error;
1402
1390
}
1403
1391
@@ -1406,13 +1394,7 @@ namespace NTypeAnnImpl {
1406
1394
return status;
1407
1395
}
1408
1396
1409
- auto type = structObj->GetTypeAnn();
1410
- const bool optional = type->GetKind() == ETypeAnnotationKind::Optional;
1411
- if (optional) {
1412
- type = type->Cast<TOptionalExprType>()->GetItemType();
1413
- }
1414
1397
TVector<const TItemExprType*> allItems;
1415
- auto structExprType = type->Cast<TStructExprType>();
1416
1398
for (auto& field: structExprType->GetItems()) {
1417
1399
const auto& fieldName = field->GetName();
1418
1400
auto prefixes = input->Child(1);
@@ -1460,7 +1442,9 @@ namespace NTypeAnnImpl {
1460
1442
}
1461
1443
1462
1444
auto structObj = *iter;
1463
- if (!EnsureStructOrOptionalStructType(*structObj, ctx.Expr)) {
1445
+ bool isOptionalStruct = false;
1446
+ const TStructExprType* structExprType = nullptr;
1447
+ if (!EnsureStructOrOptionalStructType(*structObj, isOptionalStruct, structExprType, ctx.Expr)) {
1464
1448
return IGraphTransformer::TStatus::Error;
1465
1449
}
1466
1450
TSet<TString> aliases;
@@ -11877,16 +11861,13 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
11877
11861
return IGraphTransformer::TStatus::Error;
11878
11862
}
11879
11863
11880
- if (!EnsureStructOrOptionalStructType(input->Head(), ctx.Expr)) {
11864
+ bool isOptional = false;
11865
+ const TStructExprType* structType = nullptr;
11866
+ if (!EnsureStructOrOptionalStructType(input->Head(), isOptional, structType, ctx.Expr)) {
11881
11867
return IGraphTransformer::TStatus::Error;
11882
11868
}
11883
11869
11884
- const TTypeAnnotationNode* itemType = input->Head().GetTypeAnn();
11885
- if (itemType->GetKind() == ETypeAnnotationKind::Optional) {
11886
- itemType = itemType->Cast<TOptionalExprType>()->GetItemType();
11887
- }
11888
-
11889
- for (const auto& x : itemType->Cast<TStructExprType>()->GetItems()) {
11870
+ for (const auto& x : structType->GetItems()) {
11890
11871
if (!x->GetItemType()->IsOptionalOrNull()) {
11891
11872
ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Head().Pos()), TStringBuilder() << "Expected all columns to be optional. Non optional column: " << x->GetName()));
11892
11873
return IGraphTransformer::TStatus::Error;
0 commit comments