@@ -540,7 +540,7 @@ namespace {
540540
541541 const auto paramName = func->Child (0 )->Content ();
542542 const auto calcSpec = func->Child (1 );
543- YQL_ENSURE (calcSpec->IsCallable ({" Lag" , " Lead" , " RowNumber" , " Rank" , " DenseRank" , " WindowTraits" }));
543+ YQL_ENSURE (calcSpec->IsCallable ({" Lag" , " Lead" , " RowNumber" , " Rank" , " DenseRank" , " WindowTraits" , " PercentRank " , " CumeDist " , " NTile " }));
544544
545545 auto traitsInputTypeNode = calcSpec->Child (0 );
546546 YQL_ENSURE (traitsInputTypeNode->GetTypeAnn ());
@@ -5948,7 +5948,7 @@ namespace {
59485948 }
59495949 auto currColumn = input->Child (i)->Child (0 )->Content ();
59505950 auto calcSpec = input->Child (i)->Child (1 );
5951- if (!calcSpec->IsCallable ({" WindowTraits" , " Lag" , " Lead" , " RowNumber" , " Rank" , " DenseRank" , " Void" })) {
5951+ if (!calcSpec->IsCallable ({" WindowTraits" , " Lag" , " Lead" , " RowNumber" , " Rank" , " DenseRank" , " PercentRank " , " CumeDist " , " NTile " , " Void" })) {
59525952 ctx.Expr .AddError (TIssue (ctx.Expr .GetPosition (calcSpec->Pos ()),
59535953 " Invalid traits or special function for calculation on window" ));
59545954 return IGraphTransformer::TStatus::Error;
@@ -6305,6 +6305,26 @@ namespace {
63056305 if (auto status = EnsureTypeRewrite (input->HeadRef (), ctx.Expr ); status != IGraphTransformer::TStatus::Ok) {
63066306 return status;
63076307 }
6308+ input->SetTypeAnn (ctx.Expr .MakeType <TDataExprType>(input->IsCallable (" CumeDist" ) ? EDataSlot::Double : EDataSlot::Uint64));
6309+ return IGraphTransformer::TStatus::Ok;
6310+ }
6311+
6312+ IGraphTransformer::TStatus WinNTileWrapper (const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx) {
6313+ Y_UNUSED (output);
6314+ if (!EnsureArgsCount (*input, 2 , ctx.Expr )) {
6315+ return IGraphTransformer::TStatus::Error;
6316+ }
6317+
6318+ if (auto status = EnsureTypeRewrite (input->HeadRef (), ctx.Expr ); status != IGraphTransformer::TStatus::Ok) {
6319+ return status;
6320+ }
6321+
6322+ auto expectedType = ctx.Expr .MakeType <TDataExprType>(EDataSlot::Int64);
6323+ auto status = TryConvertTo (input->ChildRef (1 ), *expectedType, ctx.Expr );
6324+ if (status.Level != IGraphTransformer::TStatus::Ok) {
6325+ return status;
6326+ }
6327+
63086328 input->SetTypeAnn (ctx.Expr .MakeType <TDataExprType>(EDataSlot::Uint64));
63096329 return IGraphTransformer::TStatus::Ok;
63106330 }
@@ -6403,7 +6423,8 @@ namespace {
64036423 return IGraphTransformer::TStatus::Repeat;
64046424 }
64056425
6406- const TTypeAnnotationNode* outputType = ctx.Expr .MakeType <TDataExprType>(EDataSlot::Uint64);
6426+ const TTypeAnnotationNode* outputType = ctx.Expr .MakeType <TDataExprType>(input->IsCallable (" PercentRank" ) ?
6427+ EDataSlot::Double : EDataSlot::Uint64);
64076428 if (!isAnsi && keyType->GetKind () == ETypeAnnotationKind::Optional) {
64086429 outputType = ctx.Expr .MakeType <TOptionalExprType>(outputType);
64096430 }
0 commit comments