(
(let $1 (DataType 'String))
(let $2 '('"key" $1))
(let $3 '('"subkey" $1))
(let $4 '('('"_logical_id" '6954) '('"_id" '"f4b7ee4d-82c64a7-4b5d11cb-37d90043") '('"_wide_channels" (StructType $2 $3))))
(let $5 (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 '"14") '('DataSize '"614") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $21 (YtTable '"Input" $18 $19 $20 '() (Void) (Void) '"/Root/plato"))
  (let $22 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $21 '('"key" '"subkey") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $22 '())))
))) $4))
(let $6 (DqCnHashShuffle (TDqOutput $5 '0) '('1) '0 '"HashV2"))
(let $7 (DataType 'Uint64))
(let $8 (OptionalType $7))
(let $9 (StructType '('"c" $7) '('"dbl_sum" $8) '('"maxk" $1) '('"mink" $1) $3))
(let $10 '('('"_logical_id" '7491) '('"_id" '"c8623374-c4371564-38324094-113005b0") '('"_wide_channels" $9)))
(let $11 (DqPhyStage '($6) (lambda '($23) (block '(
  (let $24 (NarrowSqueezeToDict (ToFlow $23) (lambda '($29 $30) $30) (lambda '($31 $32) (AsStruct '('"key" $31) '('"subkey" $32))) '('Auto 'Many)))
  (let $25 (Bool 'true))
  (let $26 (Chopper (OrderedFlatMap $24 (lambda '($33) (OrderedFlatMap (DictPayloads $33) (lambda '($34) (Sort $34 $25 (lambda '($35) (Member $35 '"key"))))))) (lambda '($36) (Member $36 '"subkey")) (lambda '($37 $38) (AggrNotEquals $37 (Member $38 '"subkey"))) (lambda '($39 $40) (block '(
    (let $41 (OptionalType (DataType 'Uint32)))
    (let $42 (lambda '($58) (Just (SafeCast $58 $7))))
    (let $43 (Nothing $8))
    (let $44 (Chain1Map $40 (lambda '($49) (block '(
      (let $50 '('Count0 (Uint64 '1)))
      (let $51 (Member $49 '"key"))
      (let $52 '('Max0 $51))
      (let $53 '('Min0 $51))
      (let $54 (IfPresent (SafeCast $51 $41) $42 $43))
      (let $55 '('Sum0 $54))
      (let $56 (AsStruct $50 $52 $53 $55 '('"key" $51) '('"subkey" (Member $49 '"subkey"))))
      (let $57 (AsStruct $50 $52 $53 $55))
      (return '($56 $57))
    ))) (lambda '($59 $60) (block '(
      (let $61 (Nth $60 '1))
      (let $62 '('Count0 (Inc (Member $61 'Count0))))
      (let $63 (Member $59 '"key"))
      (let $64 '('Max0 (AggrMax $63 (Member $61 'Max0))))
      (let $65 '('Min0 (AggrMin $63 (Member $61 'Min0))))
      (let $66 (IfPresent (SafeCast $63 $41) $42 $43))
      (let $67 '('Sum0 (AggrAdd $66 (Member $61 'Sum0))))
      (let $68 (AsStruct $62 $64 $65 $67 '('"key" $63) '('"subkey" (Member $59 '"subkey"))))
      (let $69 (AsStruct $62 $64 $65 $67))
      (return '($68 $69))
    )))))
    (let $45 (StructType '('Count0 $7) '('Max0 $1) '('Min0 $1) '('Sum0 $8) $2 $3))
    (let $46 (ListType $45))
    (let $47 (VariantType (StructType '('group $46) '('singleRow $45))))
    (let $48 (Condense1 $44 (lambda '($70) (block '(
      (let $71 (Nth $70 '0))
      (let $72 (Variant $71 'singleRow $47))
      (return '((Member $71 '"key") $72))
    ))) (lambda '($73 $74) (AggrNotEquals (Member (Nth $73 '0) '"key") (Nth $74 '0))) (lambda '($75 $76) (block '(
      (let $77 (Nth $75 '0))
      (let $78 (Visit (Nth $76 '1) 'group (lambda '($79) (Variant (Insert $79 $77) 'group $47)) 'singleRow (lambda '($80) (Variant (AsList $80 $77) 'group $47))))
      (return '((Nth $76 '0) $78))
    )))))
    (return (OrderedFlatMap $48 (lambda '($81) (block '(
      (let $82 (Visit (Nth $81 '1) 'group (lambda '($83) (IfPresent (Last $83) (lambda '($84) (OrderedMap (Collect (Map $83 (lambda '($85) (AsStruct '('"key" (Member $85 '"key")) '('"subkey" (Member $85 '"subkey")))))) (lambda '($86) (AsStruct '('Count0 (Member $84 'Count0)) '('Max0 (Member $84 'Max0)) '('Min0 (Member $84 'Min0)) '('Sum0 (Member $84 'Sum0)) '('"key" (Member $86 '"key")) '('"subkey" (Member $86 '"subkey")))))) (List $46))) 'singleRow (lambda '($87) (AsList $87))))
      (return (Map $82 (lambda '($88) (AsStruct '('Count0 (Member $88 'Count0)) '('Max0 (Member $88 'Max0)) '('Min0 (Member $88 'Min0)) '('Sum0 (Member $88 'Sum0)) '('"subkey" (Member $88 '"subkey"))))))
    )))))
  )))))
  (let $27 (Sort (Map $26 (lambda '($89) (AsStruct '('"c" (Member $89 'Count0)) '('"dbl_sum" (* (Int32 '"2") (Member $89 'Sum0))) '('"maxk" (Member $89 'Max0)) '('"mink" (Member $89 'Min0)) '('"subkey" (Member $89 '"subkey"))))) '($25 $25) (lambda '($90) '((Member $90 '"subkey") (Member $90 '"c")))))
  (let $28 (lambda '($91) (Member $91 '"c") (Member $91 '"dbl_sum") (Member $91 '"maxk") (Member $91 '"mink") (Member $91 '"subkey")))
  (return (FromFlow (ExpandMap $27 $28)))
))) $10))
(let $12 (DqCnMerge (TDqOutput $11 '0) '('('"4" '"Asc") '('0 '"Asc"))))
(let $13 (DqPhyStage '($12) (lambda '($92) (FromFlow (NarrowMap (ToFlow $92) (lambda '($93 $94 $95 $96 $97) (AsStruct '('"c" $93) '('"dbl_sum" $94) '('"maxk" $95) '('"mink" $96) '('"subkey" $97)))))) '('('"_logical_id" '7503) '('"_id" '"c94291bc-991fc921-ed1d6ba1-320d683a"))))
(let $14 '($5 $11 $13))
(let $15 '('"subkey" '"dbl_sum" '"c" '"mink" '"maxk"))
(let $16 (DqCnResult (TDqOutput $13 '0) $15))
(return (KqpPhysicalQuery '((KqpPhysicalTx $14 '($16) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $9) '0 '0)) '('('"type" '"query"))))
)
