(
(let $1 (DataType 'String))
(let $2 '('"key" $1))
(let $3 '('('"_logical_id" '6870) '('"_id" '"634a7d2e-3cfa23ff-4e194fed-3387ed5f") '('"_wide_channels" (StructType $2))))
(let $4 (DqPhyStage '() (lambda '() (block '(
  (let $16 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $17 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $16)))
  (let $18 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $19 (YtStat '('Id '"Input") '('RecordsCount '"14") '('DataSize '"614") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $20 (YtTable '"Input" $17 $18 $19 '() (Void) (Void) '"/Root/plato"))
  (let $21 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $20 '('"key") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $21 '())))
))) $3))
(let $5 (DqCnUnionAll (TDqOutput $4 '0)))
(let $6 (DataType 'Uint64))
(let $7 (OptionalType $6))
(let $8 (StructType '('"c" $6) '('"dbl_sum" $7) '('"maxk" $1) '('"mink" $1)))
(let $9 '('('"_logical_id" '7310) '('"_id" '"5fe00086-2cbb614-35c26d2f-13580af9") '('"_wide_channels" $8)))
(let $10 (DqPhyStage '($5) (lambda '($22) (block '(
  (let $23 (OptionalType (DataType 'Uint32)))
  (let $24 (lambda '($43) (Just (SafeCast $43 $6))))
  (let $25 (Nothing $7))
  (let $26 (Chain1Map (NarrowMap (WideSort (ToFlow $22) '('('0 (Bool 'false)))) (lambda '($33) (AsStruct '('"key" $33)))) (lambda '($34) (block '(
    (let $35 '('Count0 (Uint64 '1)))
    (let $36 (Member $34 '"key"))
    (let $37 '('Max0 $36))
    (let $38 '('Min0 $36))
    (let $39 (IfPresent (SafeCast $36 $23) $24 $25))
    (let $40 '('Sum0 $39))
    (let $41 (AsStruct $35 $37 $38 $40 '('"key" $36)))
    (let $42 (AsStruct $35 $37 $38 $40))
    (return '($41 $42))
  ))) (lambda '($44 $45) (block '(
    (let $46 (Nth $45 '1))
    (let $47 '('Count0 (Inc (Member $46 'Count0))))
    (let $48 (Member $44 '"key"))
    (let $49 '('Max0 (AggrMax $48 (Member $46 'Max0))))
    (let $50 '('Min0 (AggrMin $48 (Member $46 'Min0))))
    (let $51 (IfPresent (SafeCast $48 $23) $24 $25))
    (let $52 '('Sum0 (AggrAdd $51 (Member $46 'Sum0))))
    (let $53 (AsStruct $47 $49 $50 $52 '('"key" $48)))
    (let $54 (AsStruct $47 $49 $50 $52))
    (return '($53 $54))
  )))))
  (let $27 (StructType '('Count0 $6) '('Max0 $1) '('Min0 $1) '('Sum0 $7) $2))
  (let $28 (ListType $27))
  (let $29 (VariantType (StructType '('group $28) '('singleRow $27))))
  (let $30 (Condense1 $26 (lambda '($55) (block '(
    (let $56 (Nth $55 '0))
    (let $57 (Variant $56 'singleRow $29))
    (return '((Member $56 '"key") $57))
  ))) (lambda '($58 $59) (AggrNotEquals (Member (Nth $58 '0) '"key") (Nth $59 '0))) (lambda '($60 $61) (block '(
    (let $62 (Nth $60 '0))
    (let $63 (Visit (Nth $61 '1) 'group (lambda '($64) (Variant (Insert $64 $62) 'group $29)) 'singleRow (lambda '($65) (Variant (AsList $65 $62) 'group $29))))
    (return '((Nth $61 '0) $63))
  )))))
  (let $31 (Sort (Map (OrderedFlatMap $30 (lambda '($66) (block '(
    (let $67 (Visit (Nth $66 '1) 'group (lambda '($68) (IfPresent (Last $68) (lambda '($69) (OrderedMap (Collect (Map $68 (lambda '($70) (AsStruct '('"key" (Member $70 '"key")))))) (lambda '($71) (AsStruct '('Count0 (Member $69 'Count0)) '('Max0 (Member $69 'Max0)) '('Min0 (Member $69 'Min0)) '('Sum0 (Member $69 'Sum0)) '('"key" (Member $71 '"key")))))) (List $28))) 'singleRow (lambda '($72) (AsList $72))))
    (return (Map $67 (lambda '($73) (AsStruct '('Count0 (Member $73 'Count0)) '('Max0 (Member $73 'Max0)) '('Min0 (Member $73 'Min0)) '('Sum0 (Member $73 'Sum0))))))
  )))) (lambda '($74) (AsStruct '('"c" (Member $74 'Count0)) '('"dbl_sum" (* (Int32 '"2") (Member $74 'Sum0))) '('"maxk" (Member $74 'Max0)) '('"mink" (Member $74 'Min0))))) (Bool 'true) (lambda '($75) (Member $75 '"c"))))
  (let $32 (lambda '($76) (Member $76 '"c") (Member $76 '"dbl_sum") (Member $76 '"maxk") (Member $76 '"mink")))
  (return (FromFlow (ExpandMap $31 $32)))
))) $9))
(let $11 (DqCnMerge (TDqOutput $10 '0) '('('0 '"Asc"))))
(let $12 (DqPhyStage '($11) (lambda '($77) (FromFlow (NarrowMap (ToFlow $77) (lambda '($78 $79 $80 $81) (AsStruct '('"c" $78) '('"dbl_sum" $79) '('"maxk" $80) '('"mink" $81)))))) '('('"_logical_id" '7322) '('"_id" '"792ce291-acc5c9fe-92d453d7-3e25b28f"))))
(let $13 '($4 $10 $12))
(let $14 '('"dbl_sum" '"c" '"mink" '"maxk"))
(let $15 (DqCnResult (TDqOutput $12 '0) $14))
(return (KqpPhysicalQuery '((KqpPhysicalTx $13 '($15) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $8) '0 '0)) '('('"type" '"query"))))
)
