(
(let $1 (DataType 'String))
(let $2 (OptionalType $1))
(let $3 '('"key" $2))
(let $4 '('"subkey" $1))
(let $5 '('"value" $1))
(let $6 (StructType $3 $4 $5))
(let $7 '('"_wide_channels" $6))
(let $8 '('('"_logical_id" '4107) '('"_id" '"13781c72-5a66c5dd-6428b64a-f866e655") $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 '"30") '('DataSize '"1170") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $29 (YtTable '"Input" $26 $27 $28 '() (Void) (Void) '"/Root/plato"))
  (let $30 '('"key" '"subkey" '"value"))
  (let $31 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $29 $30 (Void) (Void))) '()))))
  (let $32 (lambda '($36 $37 $38) (Just $36) $37 $38))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $31 '()) (lambda '($33 $34 $35) (== $33 (String '1)))) $32)))
))) $8))
(let $10 '('('"_logical_id" '4144) '('"_id" '"5aa52632-7a05408b-5c4d3127-d9f43164") $7))
(let $11 (DqPhyStage '() (lambda '() (block '(
  (let $39 '('"subkey" (String '"9")))
  (let $40 (lambda '($41) (Nothing $2) (Member $41 '"subkey") (Member $41 '"value")))
  (return (FromFlow (ExpandMap (ToFlow (AsList (AsStruct $39 '('"value" (String '"000"))) (AsStruct $39 '('"value" (String '"001"))))) $40)))
))) $10))
(let $12 (DqCnParallelUnionAll (TDqOutput $9 '0)))
(let $13 (DqCnParallelUnionAll (TDqOutput $11 '0)))
(let $14 '('('"_logical_id" '4156) '('"_id" '"90c177e0-bb96f99d-dd5c0d8e-f3e1451d") $7))
(let $15 (DqPhyStage '($12 $13) (lambda '($42 $43) (FromFlow (Extend (ToFlow $42) (ToFlow $43)))) $14))
(let $16 (DqCnHashShuffle (TDqOutput $15 '0) '('0 '1) '0 '"HashV2"))
(let $17 (StructType '('"agglist1" (ListType $1)) $3 $4 $5))
(let $18 '('('"_logical_id" '4822) '('"_id" '"bd90e5c1-a9c10d8b-19f99fb6-e5e381af") '('"_wide_channels" $17)))
(let $19 (DqPhyStage '($16) (lambda '($44) (block '(
  (let $45 (NarrowSqueezeToDict (ToFlow $44) (lambda '($50 $51 $52) '($50 $51)) (lambda '($53 $54 $55) (AsStruct '('"key" $53) '('"subkey" $54) '('"value" $55))) '('Auto 'Many)))
  (let $46 (Bool 'true))
  (let $47 (Chopper (OrderedFlatMap $45 (lambda '($56) (OrderedFlatMap (DictPayloads $56) (lambda '($57) (Sort $57 $46 (lambda '($58) (Member $58 '"value"))))))) (lambda '($59) '((Member $59 '"key") (Member $59 '"subkey"))) (lambda '($60 $61) (Or (AggrNotEquals (Nth $60 '0) (Member $61 '"key")) (AggrNotEquals (Nth $60 '1) (Member $61 '"subkey")))) (lambda '($62 $63) (block '(
    (let $64 (FromFlow $63))
    (let $65 (QueueCreate $6 (Void) (Uint64 '0) (DependsOn $64)))
    (let $66 (Uint64 '"18446744073709551615"))
    (let $67 (Chain1Map (ToFlow (PreserveStream $64 $65 $66)) (lambda '($68) (block '(
      (let $69 (QueueRange $65 (Uint64 '1) $66 (DependsOn $68)))
      (let $70 (Member $68 '"value"))
      (let $71 (Fold (FlatMap $69 (lambda '($74) $74)) (AsList $70) (lambda '($75 $76) (Insert $76 (Member $75 '"value")))))
      (let $72 '('AggregateList0 $71))
      (let $73 (AsStruct $72 '('"key" (Member $68 '"key")) '('"subkey" (Member $68 '"subkey")) '('"value" $70)))
      (return '($73 (AsStruct $72)))
    ))) (lambda '($77 $78) (block '(
      (let $79 (Nth $78 '1))
      (let $80 (AsStruct '('AggregateList0 (Member $79 'AggregateList0)) '('"key" (Member $77 '"key")) '('"subkey" (Member $77 '"subkey")) '('"value" (Member $77 '"value"))))
      (return '($80 $79))
    )))))
    (return (OrderedMap $67 (lambda '($81) (Nth $81 '0))))
  )))))
  (let $48 (Sort (Map $47 (lambda '($82) (AsStruct '('"agglist1" (Member $82 'AggregateList0)) '('"key" (Member $82 '"key")) '('"subkey" (Member $82 '"subkey")) '('"value" (Member $82 '"value"))))) $46 (lambda '($83) (Member $83 '"value"))))
  (let $49 (lambda '($84) (Member $84 '"agglist1") (Member $84 '"key") (Member $84 '"subkey") (Member $84 '"value")))
  (return (FromFlow (ExpandMap $48 $49)))
))) $18))
(let $20 (DqCnMerge (TDqOutput $19 '0) '('('"3" '"Asc"))))
(let $21 (DqPhyStage '($20) (lambda '($85) (FromFlow (NarrowMap (ToFlow $85) (lambda '($86 $87 $88 $89) (AsStruct '('"agglist1" $86) '('"key" $87) '('"subkey" $88) '('"value" $89)))))) '('('"_logical_id" '4834) '('"_id" '"8e8d45ca-e31c48fc-8a2f2c8a-addf7bae"))))
(let $22 '($9 $11 $15 $19 $21))
(let $23 '('"key" '"subkey" '"value" '"agglist1"))
(let $24 (DqCnResult (TDqOutput $21 '0) $23))
(return (KqpPhysicalQuery '((KqpPhysicalTx $22 '($24) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $17) '0 '0)) '('('"type" '"query"))))
)
