(
(let $1 (DataType 'Uint64))
(let $2 '('_yql_RowNumber0 $1))
(let $3 '('_yql_RowNumber3 $1))
(let $4 (DataType 'String))
(let $5 '('"key" $4))
(let $6 '('"subkey" $4))
(let $7 (StructType $2 $3 $5 $6))
(let $8 '('('"_logical_id" '6057) '('"_id" '"312b0d9b-207e6f67-848bbb86-34712c57") '('"_wide_channels" $7)))
(let $9 (DqPhyStage '() (lambda '() (block '(
  (let $25 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $26 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $25)))
  (let $27 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $28 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $29 (YtTable '"Input" $26 $27 $28 '() (Void) (Void) '"/Root/plato"))
  (let $30 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $29 '('"key" '"subkey") (Void) (Void))) '('('"syscolumns" '('"num")))))))
  (let $31 (lambda '($32 $33 $34) $32 $32 $33 $34))
  (return (FromFlow (WideMap (DqReadWideWrap $30 '()) $31)))
))) $8))
(let $10 (DqCnUnionAll (TDqOutput $9 '0)))
(let $11 (Bool 'true))
(let $12 (Uint64 '1))
(let $13 (StructType '('Count0 $1) $2 '('_yql_RowNumber1 $1) $3 $5 $6))
(let $14 '('('"_logical_id" '6168) '('"_id" '"21513023-e51d7401-d2c42fbf-5e16851f") '('"_partition_mode" '"aggregate") '('"_wide_channels" $13)))
(let $15 (DqPhyStage '($10) (lambda '($35) (block '(
  (let $36 (FromFlow (NarrowMap (WideSort (ToFlow $35) '('('3 $11))) (lambda '($41 $42 $43 $44) (AsStruct '('_yql_RowNumber0 $41) '('_yql_RowNumber3 $42) '('"key" $43) '('"subkey" $44))))))
  (let $37 (QueueCreate $7 (Void) (Uint64 '0) (DependsOn $36)))
  (let $38 (Uint64 '"18446744073709551615"))
  (let $39 (Chain1Map (ToFlow (PreserveStream $36 $37 $38)) (lambda '($45) (block '(
    (let $46 (QueueRange $37 $12 $38 (DependsOn $45)))
    (let $47 '('Count0 (+ $12 (* $12 (Length (Map (Filter $46 (lambda '($50) (Exists $50))) (lambda '($51) (AsStruct))))))))
    (let $48 '('_yql_RowNumber1 $12))
    (let $49 (AsStruct $47 '('_yql_RowNumber0 (Member $45 '_yql_RowNumber0)) $48 '('_yql_RowNumber3 (Member $45 '_yql_RowNumber3)) '('"key" (Member $45 '"key")) '('"subkey" (Member $45 '"subkey"))))
    (return '($49 (AsStruct $47 $48)))
  ))) (lambda '($52 $53) (block '(
    (let $54 (Nth $53 '1))
    (let $55 '('Count0 (Member $54 'Count0)))
    (let $56 '('_yql_RowNumber1 (Inc (Member $54 '_yql_RowNumber1))))
    (let $57 (AsStruct $55 '('_yql_RowNumber0 (Member $52 '_yql_RowNumber0)) $56 '('_yql_RowNumber3 (Member $52 '_yql_RowNumber3)) '('"key" (Member $52 '"key")) '('"subkey" (Member $52 '"subkey"))))
    (return '($57 (AsStruct $55 $56)))
  )))))
  (let $40 (lambda '($58) (block '(
    (let $59 (Nth $58 '0))
    (return (Member $59 'Count0) (Member $59 '_yql_RowNumber0) (Member $59 '_yql_RowNumber1) (Member $59 '_yql_RowNumber3) (Member $59 '"key") (Member $59 '"subkey"))
  ))))
  (return (FromFlow (ExpandMap $39 $40)))
))) $14))
(let $16 (DqCnUnionAll (TDqOutput $15 '0)))
(let $17 (StructType $5 '('"rn1" $1) '('"rn2" $1) '('"rn3" $1) '('"rn4" $1) $6 '('"w2_cnt" $1)))
(let $18 '('('"_logical_id" '7147) '('"_id" '"d5bcd9ac-3ae2d11a-d8d8643-9ffc65af") '('"_wide_channels" $17)))
(let $19 (DqPhyStage '($16) (lambda '($60) (block '(
  (let $61 (Chain1Map (NarrowMap (WideSort (ToFlow $60) '('('5 (Bool 'false)))) (lambda '($64 $65 $66 $67 $68 $69) (AsStruct '('Count0 $64) '('_yql_RowNumber0 $65) '('_yql_RowNumber1 $66) '('_yql_RowNumber3 $67) '('"key" $68) '('"subkey" $69)))) (lambda '($70) (block '(
    (let $71 '('_yql_RowNumber2 $12))
    (let $72 (AsStruct '('Count0 (Member $70 'Count0)) '('_yql_RowNumber0 (Member $70 '_yql_RowNumber0)) '('_yql_RowNumber1 (Member $70 '_yql_RowNumber1)) $71 '('_yql_RowNumber3 (Member $70 '_yql_RowNumber3)) '('"key" (Member $70 '"key")) '('"subkey" (Member $70 '"subkey"))))
    (return '($72 (AsStruct $71)))
  ))) (lambda '($73 $74) (block '(
    (let $75 '('_yql_RowNumber2 (Inc (Member (Nth $74 '1) '_yql_RowNumber2))))
    (let $76 (AsStruct '('Count0 (Member $73 'Count0)) '('_yql_RowNumber0 (Member $73 '_yql_RowNumber0)) '('_yql_RowNumber1 (Member $73 '_yql_RowNumber1)) $75 '('_yql_RowNumber3 (Member $73 '_yql_RowNumber3)) '('"key" (Member $73 '"key")) '('"subkey" (Member $73 '"subkey"))))
    (return '($76 (AsStruct $75)))
  )))))
  (let $62 (Sort (Map $61 (lambda '($77) (block '(
    (let $78 (Nth $77 '0))
    (return (AsStruct '('"key" (Member $78 '"key")) '('"rn1" (Member $78 '_yql_RowNumber0)) '('"rn2" (Member $78 '_yql_RowNumber1)) '('"rn3" (Member $78 '_yql_RowNumber2)) '('"rn4" (Member $78 '_yql_RowNumber3)) '('"subkey" (Member $78 '"subkey")) '('"w2_cnt" (Member $78 'Count0))))
  )))) $11 (lambda '($79) (Member $79 '"subkey"))))
  (let $63 (lambda '($80) (Member $80 '"key") (Member $80 '"rn1") (Member $80 '"rn2") (Member $80 '"rn3") (Member $80 '"rn4") (Member $80 '"subkey") (Member $80 '"w2_cnt")))
  (return (FromFlow (ExpandMap $62 $63)))
))) $18))
(let $20 (DqCnMerge (TDqOutput $19 '0) '('('5 '"Asc"))))
(let $21 (DqPhyStage '($20) (lambda '($81) (FromFlow (NarrowMap (ToFlow $81) (lambda '($82 $83 $84 $85 $86 $87 $88) (AsStruct '('"key" $82) '('"rn1" $83) '('"rn2" $84) '('"rn3" $85) '('"rn4" $86) '('"subkey" $87) '('"w2_cnt" $88)))))) '('('"_logical_id" '7159) '('"_id" '"186ee3f0-ea61e737-5ce2ec02-4a0db0a8"))))
(let $22 '($9 $15 $19 $21))
(let $23 '('"key" '"subkey" '"rn1" '"rn2" '"w2_cnt" '"rn3" '"rn4"))
(let $24 (DqCnResult (TDqOutput $21 '0) $23))
(return (KqpPhysicalQuery '((KqpPhysicalTx $22 '($24) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $17) '0 '0)) '('('"type" '"query"))))
)
