(
(let $1 (DataType 'String))
(let $2 '('"key" $1))
(let $3 '('"subkey" $1))
(let $4 '('"value" $1))
(let $5 (StructType $2 $3 $4))
(let $6 '('('"_logical_id" '7343) '('"_id" '"d86a9478-14711e9d-7a0a4aaa-922bc77a") '('"_wide_channels" $5)))
(let $7 (DqPhyStage '() (lambda '() (block '(
  (let $17 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $18 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $17)))
  (let $19 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $20 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $21 (YtTable '"Input" $18 $19 $20 '() (Void) (Void) '"/Root/plato"))
  (let $22 '('"key" '"subkey" '"value"))
  (let $23 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $21 $22 (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $23 '())))
))) $6))
(let $8 (DqCnUnionAll (TDqOutput $7 '0)))
(let $9 (OptionalType $1))
(let $10 (StructType $2 '('"nkey" $9) '('"pkey" $9) '('"position_cnt" (DataType 'Uint64)) $3 $4))
(let $11 '('('"_logical_id" '8898) '('"_id" '"664f818d-c0853183-88cd1c05-5a162357") '('"_wide_channels" $10)))
(let $12 (DqPhyStage '($8) (lambda '($24) (block '(
  (let $25 (FromFlow (NarrowMap (WideSort (ToFlow $24) '('('2 (Bool 'false)))) (lambda '($35 $36 $37) (AsStruct '('"key" $35) '('"subkey" $36) '('"value" $37))))))
  (let $26 (Uint64 '1))
  (let $27 (QueueCreate $5 (Uint64 '"4") $26 (DependsOn $25)))
  (let $28 (Uint64 '0))
  (let $29 (lambda '($47) (Just (Member $47 '"key"))))
  (let $30 (Nothing $9))
  (let $31 (Uint64 '2))
  (let $32 (Chain1Map (ToFlow (PreserveStream $25 $27 $26)) (lambda '($38) (block '(
    (let $39 (DependsOn $38))
    (let $40 (QueuePeek $27 $28 $39))
    (let $41 (IfPresent $40 $29 $30))
    (let $42 (QueuePeek $27 $31 $39))
    (let $43 (IfPresent $42 $29 $30))
    (let $44 '('_yql_RowNumber0 $26))
    (let $45 (AsStruct '('_yql_Lag0 $41) '('_yql_Lead0 $43) $44 '('"key" (Member $38 '"key")) '('"subkey" (Member $38 '"subkey")) '('"value" (Member $38 '"value"))))
    (let $46 (AsStruct '('_yql_Lag0 (Void)) '('_yql_Lead0 (Void)) $44))
    (return '($45 $46))
  ))) (lambda '($48 $49) (block '(
    (let $50 (DependsOn $48))
    (let $51 (QueuePeek $27 $28 $50))
    (let $52 (IfPresent $51 $29 $30))
    (let $53 (QueuePeek $27 $31 $50))
    (let $54 (IfPresent $53 $29 $30))
    (let $55 (Nth $49 '1))
    (let $56 '('_yql_RowNumber0 (Inc (Member $55 '_yql_RowNumber0))))
    (let $57 (AsStruct '('_yql_Lag0 $52) '('_yql_Lead0 $54) $56 '('"key" (Member $48 '"key")) '('"subkey" (Member $48 '"subkey")) '('"value" (Member $48 '"value"))))
    (let $58 (AsStruct '('_yql_Lag0 (Member $55 '_yql_Lag0)) '('_yql_Lead0 (Member $55 '_yql_Lead0)) $56))
    (return '($57 $58))
  )))))
  (let $33 (Sort (Map $32 (lambda '($59) (block '(
    (let $60 (Nth $59 '0))
    (return (AsStruct '('"key" (Member $60 '"key")) '('"nkey" (Member $60 '_yql_Lead0)) '('"pkey" (Member $60 '_yql_Lag0)) '('"position_cnt" (- (Member $60 '_yql_RowNumber0) (Int32 '1))) '('"subkey" (Member $60 '"subkey")) '('"value" (Member $60 '"value"))))
  )))) (Bool 'true) (lambda '($61) (Member $61 '"position_cnt"))))
  (let $34 (lambda '($62) (Member $62 '"key") (Member $62 '"nkey") (Member $62 '"pkey") (Member $62 '"position_cnt") (Member $62 '"subkey") (Member $62 '"value")))
  (return (FromFlow (ExpandMap $33 $34)))
))) $11))
(let $13 (DqCnMerge (TDqOutput $12 '0) '('('"3" '"Asc"))))
(let $14 (DqPhyStage '($13) (lambda '($63) (FromFlow (NarrowMap (ToFlow $63) (lambda '($64 $65 $66 $67 $68 $69) (AsStruct '('"key" $64) '('"nkey" $65) '('"pkey" $66) '('"position_cnt" $67) '('"subkey" $68) '('"value" $69)))))) '('('"_logical_id" '8910) '('"_id" '"b5607d0a-75448c41-38a459f3-1caed760"))))
(let $15 '($7 $12 $14))
(let $16 (DqCnResult (TDqOutput $14 '0) '()))
(return (KqpPhysicalQuery '((KqpPhysicalTx $15 '($16) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $10) '0 '0)) '('('"type" '"query"))))
)
