(
(declare %kqp%tx_result_binding_0_0 (OptionalType (StructType '('Avg0 (OptionalType (DataType 'Double))) '('Min0 (DataType 'String)) '('Sum0 (OptionalType (DataType 'Int64))))))
(let $1 '('"key" '"subkey" '"value"))
(let $2 (Uint64 '1))
(let $3 (DataType 'Double))
(let $4 (OptionalType (TupleType $3 (DataType 'Uint64))))
(let $5 (DataType 'Int64))
(let $6 (OptionalType $5))
(let $7 (Bool 'false))
(let $8 (DataType 'String))
(let $9 (StructType '('_yql_agg_0 $4) '('_yql_agg_1 $8) '('_yql_agg_2 $6)))
(let $10 '('('"_logical_id" '3571) '('"_id" '"467db02e-eb360ede-428f3732-addb3150") '('"_wide_channels" $9)))
(let $11 (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) '('HasRLS '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $28 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $29 (YtTable '"Input" $26 $27 $28 '() (Void) (Void) '"/Root/plato"))
  (let $30 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $29 $1 (Void) (Void) (Void))) '()))))
  (let $31 (OptionalType (DataType 'Int32)))
  (let $32 (lambda '($43) (Just '((Convert $43 'Double) $2))))
  (let $33 (Nothing $4))
  (let $34 (lambda '($44) (Just (SafeCast $44 $5))))
  (let $35 (Nothing $6))
  (let $36 (lambda '($38 $39 $40) (block '(
    (let $41 (IfPresent (SafeCast $38 $31) $32 $33))
    (let $42 (IfPresent (SafeCast $39 $31) $34 $35))
    (return $41 $40 $42)
  ))))
  (let $37 (lambda '($51 $52 $53 $54 $55 $56) (block '(
    (let $57 (SafeCast $51 $31))
    (let $58 (IfPresent $57 $32 $33))
    (let $59 (IfPresent $54 (lambda '($61) (IfPresent $57 (lambda '($62) (Just '((AggrAdd (Nth $61 '0) (Convert $62 'Double)) (Inc (Nth $61 '1))))) (Just $61))) $58))
    (let $60 (IfPresent (SafeCast $52 $31) $34 $35))
    (return $59 (AggrMin $53 $55) (AggrAdd $60 $56))
  ))))
  (return (FromFlow (WideCondense1 (DqReadWideWrap $30 '()) $36 (lambda '($45 $46 $47 $48 $49 $50) $7) $37)))
))) $10))
(let $12 (DqCnUnionAll (TDqOutput $11 '0)))
(let $13 (OptionalType $3))
(let $14 (OptionalType (StructType '('Avg0 $13) '('Min0 $8) '('Sum0 $6))))
(let $15 (DqPhyStage '($12) (lambda '($63) (block '(
  (let $64 (lambda '($67 $68 $69) $67 $68 $69))
  (let $65 (lambda '($76 $77 $78 $79 $80 $81) (block '(
    (let $82 (IfPresent $76 (lambda '($83) (IfPresent $79 (lambda '($84) (Just '((AggrAdd (Nth $83 '0) (Nth $84 '0)) (AggrAdd (Nth $83 '1) (Nth $84 '1))))) $76)) $79))
    (return $82 (AggrMin $77 $80) (AggrAdd $78 $81))
  ))))
  (let $66 (WideCondense1 (ToFlow $63) $64 (lambda '($70 $71 $72 $73 $74 $75) $7) $65))
  (return (FromFlow (Condense (NarrowMap (Take $66 $2) (lambda '($85 $86 $87) (block '(
    (let $88 (IfPresent $85 (lambda '($89) (Just (Div (Nth $89 '0) (Nth $89 '1)))) (Nothing $13)))
    (return (AsStruct '('Avg0 $88) '('Min0 $86) '('Sum0 $87)))
  )))) (Nothing $14) (lambda '($90 $91) $7) (lambda '($92 $93) (Just $92)))))
))) '('('"_logical_id" '3909) '('"_id" '"fe9094d1-25c658f2-5f652f03-2dcfaf18"))))
(let $16 (DqCnValue (TDqOutput $15 '0)))
(let $17 (KqpPhysicalTx '($11 $15) '($16) '() '('('"type" '"compute"))))
(let $18 '"%kqp%tx_result_binding_0_0")
(let $19 (OptionalType $8))
(let $20 '('('"_logical_id" '3963) '('"_id" '"4abb32-20497829-189f5cbb-735bccac") '('"_partition_mode" '"single")))
(let $21 (DqPhyStage '() (lambda '() (block '(
  (let $94 %kqp%tx_result_binding_0_0)
  (let $95 (IfPresent (Member $94 'Sum0) (lambda '($96) (Just (SafeCast $96 $8))) (Nothing $19)))
  (return (Iterator (AsList (AsStruct '('"key" (Member $94 'Avg0)) '('"subkey" $95) '('"value" (Member $94 'Min0))))))
))) $20))
(let $22 (DqCnResult (TDqOutput $21 '0) $1))
(let $23 (KqpTxResultBinding $14 '0 '0))
(let $24 (KqpPhysicalTx '($21) '($22) '('($18 $23)) '('('"type" '"generic"))))
(return (KqpPhysicalQuery '($17 $24) '((KqpTxResultBinding (ListType (StructType '('"key" $13) '('"subkey" $19) '('"value" $19))) '1 '0)) '('('"type" '"query"))))
)
