(
(let $1 (DataType 'String))
(let $2 (OptionalType $1))
(let $3 '('"key" $2))
(let $4 '('pkey (TupleType $2 $1)))
(let $5 '('"subkey" $1))
(let $6 '('"value" $1))
(let $7 (StructType $3 $4 $5 $6))
(let $8 '('"_wide_channels" $7))
(let $9 '('('"_logical_id" '4634) '('"_id" '"57d2f9c7-2a3288f0-9761befe-c1c36056") $8))
(let $10 (DqPhyStage '() (lambda '() (block '(
  (let $28 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $29 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $28)))
  (let $30 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" '"false")))))
  (let $31 (YtStat '('Id '"Input") '('RecordsCount '"30") '('DataSize '"1170") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $32 (YtTable '"Input" $29 $30 $31 '() (Void) (Void) '"/Root/plato"))
  (let $33 '('"key" '"subkey" '"value"))
  (let $34 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $32 $33 (Void) (Void))) '()))))
  (let $35 (lambda '($39 $40 $41) (block '(
    (let $42 (Just $39))
    (return $42 '($42 $40) $40 $41)
  ))))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $34 '()) (lambda '($36 $37 $38) (== $36 (String '1)))) $35)))
))) $9))
(let $11 '('('"_logical_id" '4675) '('"_id" '"5260e957-b8c827dc-9b2fb0c-d62e8803") $8))
(let $12 (DqPhyStage '() (lambda '() (block '(
  (let $43 '('"subkey" (String '"9")))
  (let $44 (lambda '($45) (block '(
    (let $46 (Nothing $2))
    (let $47 (Member $45 '"subkey"))
    (return $46 '($46 $47) $47 (Member $45 '"value"))
  ))))
  (return (FromFlow (ExpandMap (ToFlow (AsList (AsStruct $43 '('"value" (String '"000"))) (AsStruct $43 '('"value" (String '"001"))))) $44)))
))) $11))
(let $13 (DqCnParallelUnionAll (TDqOutput $10 '0)))
(let $14 (DqCnParallelUnionAll (TDqOutput $12 '0)))
(let $15 '"_yql_key_selector_0")
(let $16 (StructType '($15 $1) $3 $4 $5 $6))
(let $17 '('('"_logical_id" '4782) '('"_id" '"2c8d6eb8-aaf21d2e-105c61ee-359c08b9") '('"_wide_channels" $16)))
(let $18 (DqPhyStage '($13 $14) (lambda '($48 $49) (block '(
  (let $50 (lambda '($51 $52 $53 $54) (StablePickle $52) $51 $52 $53 $54))
  (return (FromFlow (Extend (WideMap (ToFlow $48) $50) (WideMap (ToFlow $49) $50))))
))) $17))
(let $19 (DqCnHashShuffle (TDqOutput $18 '0) '('0) '0 '"HashV2"))
(let $20 (StructType '('"agglist1" (ListType $1)) $3 $5 $6))
(let $21 '('('"_logical_id" '5860) '('"_id" '"9f8a222-7864910d-da51ca6e-2a2fb9f") '('"_wide_channels" $20)))
(let $22 (DqPhyStage '($19) (lambda '($55) (block '(
  (let $56 (NarrowSqueezeToDict (ToFlow $55) (lambda '($61 $62 $63 $64 $65) $61) (lambda '($66 $67 $68 $69 $70) (AsStruct '($15 $66) '('"key" $67) '('pkey $68) '('"subkey" $69) '('"value" $70))) '('Auto 'Many)))
  (let $57 (Bool 'true))
  (let $58 (Chopper (Map (OrderedFlatMap $56 (lambda '($71) (OrderedFlatMap (DictPayloads $71) (lambda '($72) (Sort $72 $57 (lambda '($73) (Member $73 '"value"))))))) (lambda '($74) (AsStruct '('"key" (Member $74 '"key")) '('pkey (Member $74 'pkey)) '('"subkey" (Member $74 '"subkey")) '('"value" (Member $74 '"value"))))) (lambda '($75) (StablePickle (Member $75 'pkey))) (lambda '($76 $77) (AggrNotEquals $76 (StablePickle (Member $77 'pkey)))) (lambda '($78 $79) (block '(
    (let $80 (FromFlow $79))
    (let $81 (QueueCreate $7 (Void) (Uint64 '0) (DependsOn $80)))
    (let $82 (Uint64 '"18446744073709551615"))
    (let $83 (Chain1Map (ToFlow (PreserveStream $80 $81 $82)) (lambda '($84) (block '(
      (let $85 (QueueRange $81 (Uint64 '1) $82 (DependsOn $84)))
      (let $86 (Member $84 '"value"))
      (let $87 (Fold (FlatMap $85 (lambda '($90) $90)) (AsList $86) (lambda '($91 $92) (Insert $92 (Member $91 '"value")))))
      (let $88 '('AggregateList0 $87))
      (let $89 (AsStruct $88 '('"key" (Member $84 '"key")) '('pkey (Member $84 'pkey)) '('"subkey" (Member $84 '"subkey")) '('"value" $86)))
      (return '($89 (AsStruct $88)))
    ))) (lambda '($93 $94) (block '(
      (let $95 (Nth $94 '1))
      (let $96 (AsStruct '('AggregateList0 (Member $95 'AggregateList0)) '('"key" (Member $93 '"key")) '('pkey (Member $93 'pkey)) '('"subkey" (Member $93 '"subkey")) '('"value" (Member $93 '"value"))))
      (return '($96 $95))
    )))))
    (return (OrderedMap $83 (lambda '($97) (block '(
      (let $98 (Nth $97 '0))
      (return (AsStruct '('AggregateList0 (Member $98 'AggregateList0)) '('"key" (Member $98 '"key")) '('"subkey" (Member $98 '"subkey")) '('"value" (Member $98 '"value"))))
    )))))
  )))))
  (let $59 (Sort (Map $58 (lambda '($99) (AsStruct '('"agglist1" (Member $99 'AggregateList0)) '('"key" (Member $99 '"key")) '('"subkey" (Member $99 '"subkey")) '('"value" (Member $99 '"value"))))) $57 (lambda '($100) (Member $100 '"value"))))
  (let $60 (lambda '($101) (Member $101 '"agglist1") (Member $101 '"key") (Member $101 '"subkey") (Member $101 '"value")))
  (return (FromFlow (ExpandMap $59 $60)))
))) $21))
(let $23 (DqCnMerge (TDqOutput $22 '0) '('('"3" '"Asc"))))
(let $24 (DqPhyStage '($23) (lambda '($102) (FromFlow (NarrowMap (ToFlow $102) (lambda '($103 $104 $105 $106) (AsStruct '('"agglist1" $103) '('"key" $104) '('"subkey" $105) '('"value" $106)))))) '('('"_logical_id" '5872) '('"_id" '"92a5b320-c0618c2c-a37d16bc-998df9ce"))))
(let $25 '($10 $12 $18 $22 $24))
(let $26 '('"key" '"subkey" '"value" '"agglist1"))
(let $27 (DqCnResult (TDqOutput $24 '0) $26))
(return (KqpPhysicalQuery '((KqpPhysicalTx $25 '($27) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $20) '0 '0)) '('('"type" '"query"))))
)
