@@ -340,7 +340,7 @@ TStatus AnnotateReadTableRanges(const TExprNode::TPtr& node, TExprContext& ctx,
340340 size_t argCount = (olapTable || index) ? 6 : 5 ;
341341
342342 // prefix
343- if (!EnsureMinArgsCount (*node, argCount, ctx) && EnsureMaxArgsCount (*node, argCount + 1 , ctx)) {
343+ if (!EnsureMinArgsCount (*node, argCount, ctx) && EnsureMaxArgsCount (*node, argCount + 3 , ctx)) {
344344 return TStatus::Error;
345345 }
346346
@@ -375,8 +375,34 @@ TStatus AnnotateReadTableRanges(const TExprNode::TPtr& node, TExprContext& ctx,
375375 }
376376
377377 if (TKqlReadTableRanges::Match (node.Get ())) {
378+ if (node->ChildrenSize () > TKqlReadTableRanges::idx_PredicateExpr) {
379+ auto & lambda = node->ChildRef (TKqlReadTableRanges::idx_PredicateExpr);
380+ auto rowType = GetReadTableRowType (ctx, tablesData, cluster, table.first , node->Pos (), withSystemColumns);
381+ if (!rowType) {
382+ return TStatus::Error;
383+ }
384+ if (!UpdateLambdaAllArgumentsTypes (lambda, {rowType}, ctx)) {
385+ return IGraphTransformer::TStatus::Error;
386+ }
387+ if (!lambda->GetTypeAnn ()) {
388+ return IGraphTransformer::TStatus::Repeat;
389+ }
390+ }
378391 node->SetTypeAnn (ctx.MakeType <TListExprType>(rowType));
379392 } else if (TKqlReadTableIndexRanges::Match (node.Get ())) {
393+ if (node->ChildrenSize () > TKqlReadTableIndexRanges::idx_PredicateExpr) {
394+ auto & lambda = node->ChildRef (TKqlReadTableIndexRanges::idx_PredicateExpr);
395+ auto rowType = GetReadTableRowType (ctx, tablesData, cluster, table.first , node->Pos (), withSystemColumns);
396+ if (!rowType) {
397+ return TStatus::Error;
398+ }
399+ if (!UpdateLambdaAllArgumentsTypes (lambda, {rowType}, ctx)) {
400+ return IGraphTransformer::TStatus::Error;
401+ }
402+ if (!lambda->GetTypeAnn ()) {
403+ return IGraphTransformer::TStatus::Repeat;
404+ }
405+ }
380406 node->SetTypeAnn (ctx.MakeType <TListExprType>(rowType));
381407 } else if (TKqpReadTableRanges::Match (node.Get ())) {
382408 node->SetTypeAnn (ctx.MakeType <TFlowExprType>(rowType));
0 commit comments