(
(declare %kqp%tx_result_binding_0_0 (OptionalType (StructType '('Avg0 (OptionalType (DataType 'Double))) '('Avg1 (OptionalType (DataType 'Double))) '('Count0 (DataType 'Uint64)) '('Count1 (DataType 'Uint64)) '('Max0 (OptionalType (DataType 'Uint32))) '('Sum0 (OptionalType (DataType 'Uint64))))))
(let $1 '@@["StructType";[["key";["DataType";"Uint32"]];["subkey";["OptionalType";["DataType";"Uint32"]]]]]@@)
(let $2 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $1)))
(let $3 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
(let $4 (YtStat '('Id '"Input") '('RecordsCount '"5") '('DataSize '"128") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
(let $5 (YtTable '"Input" $2 $3 $4 '() (Void) (Void) '"/Root/plato"))
(let $6 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $5 '('"subkey") (Void) (Void))) '()))))
(let $7 (DqReadWideWrap $6 '()))
(let $8 (Uint64 '1))
(let $9 (lambda '($78) (Just '((Convert $78 'Double) $8))))
(let $10 (DataType 'Double))
(let $11 (DataType 'Uint64))
(let $12 (OptionalType (TupleType $10 $11)))
(let $13 (Nothing $12))
(let $14 (Bool 'false))
(let $15 (OptionalType $12))
(let $16 (Nothing $15))
(let $17 (OptionalType $11))
(let $18 (Nothing $17))
(let $19 (OptionalType $17))
(let $20 (Nothing $19))
(let $21 '('"_logical_id" '15005))
(let $22 (OptionalType (DataType 'Uint32)))
(let $23 (OptionalType $22))
(let $24 (StructType '('_yql_agg_0 $15) '('_yql_agg_1 $15) '('_yql_agg_2 $17) '('_yql_agg_3 $17) '('_yql_agg_4 $23) '('_yql_agg_5 $19)))
(let $25 '('"_wide_channels" $24))
(let $26 '($21 '('"_id" '"ac7a2732-bb784828-a36ecda7-f32eb789") $25))
(let $27 (DqPhyStage '() (lambda '() (block '(
  (let $72 (lambda '($76) (block '(
    (let $77 (IfPresent $76 $9 $13))
    (return $77 $8 $76)
  ))))
  (let $73 (lambda '($83 $84 $85 $86) (block '(
    (let $87 (IfPresent $83 $9 $13))
    (let $88 (IfPresent $84 (lambda '($89) (IfPresent $83 (lambda '($90) (Just '((AggrAdd (Nth $89 '0) (Convert $90 'Double)) (Inc (Nth $89 '1))))) (Just $89))) $87))
    (return $88 (AggrAdd $85 $8) (AggrMax $83 $86))
  ))))
  (let $74 (WideCondense1 $7 $72 (lambda '($79 $80 $81 $82) $14) $73))
  (let $75 (lambda '($91 $92 $93) (Just $91) $16 (Just $92) $18 (Just $93) $20))
  (return (FromFlow (WideMap $74 $75)))
))) $26))
(let $28 (lambda '($95 $96) $95))
(let $29 (lambda '($97 $98 $99) $99))
(let $30 (lambda '($100 $101) $101))
(let $31 (lambda '() (DqPhyHashCombine (WideToBlocks (FromFlow $7)) '-1073741824 (lambda '($94) (/ $94 (Uint32 '"2"))) $28 $29 $30)))
(let $32 '($21 '('"_id" '"cad0a985-6f0ca6e5-e7451582-77135d4e") '('"_wide_channels" (StructType '('_yql_preagg_Avg0 $22)))))
(let $33 (DqPhyStage '() $31 $32))
(let $34 '('0))
(let $35 (DqCnHashShuffle (TDqOutput $33 '0) $34 '0 '"HashV2"))
(let $36 (lambda '($106) $106))
(let $37 (lambda '($107 $108)))
(let $38 (Nothing $23))
(let $39 '('('"_logical_id" '13862) '('"_id" '"62085fe2-518a7f76-22737031-8890d15a") $25))
(let $40 (DqPhyStage '($35) (lambda '($102) (block '(
  (let $103 (WideCombiner (ToFlow (WideFromBlocks $102)) '"" $36 $37 $37 $36))
  (let $104 (Condense1 (NarrowMap $103 (lambda '($109) (AsStruct '('_yql_preagg_Avg0 $109)))) (lambda '($110) (IfPresent (Member $110 '_yql_preagg_Avg0) $9 $13)) (lambda '($111 $112) $14) (lambda '($113 $114) (block '(
    (let $115 (Member $113 '_yql_preagg_Avg0))
    (let $116 (IfPresent $115 $9 $13))
    (return (IfPresent $114 (lambda '($117) (IfPresent $115 (lambda '($118) (Just '((AggrAdd (Nth $117 '0) (Convert $118 'Double)) (Inc (Nth $117 '1))))) (Just $117))) $116))
  )))))
  (let $105 (lambda '($119) $16 (Just $119) $18 $18 $38 $20))
  (return (FromFlow (ExpandMap $104 $105)))
))) $39))
(let $41 '($21 '('"_id" '"b9d2a307-fa8416ab-41ab8a4d-dc62876c") '('"_wide_channels" (StructType '('_yql_preagg_Count0 $22)))))
(let $42 (DqPhyStage '() $31 $41))
(let $43 (DqCnHashShuffle (TDqOutput $42 '0) $34 '0 '"HashV2"))
(let $44 '('('"_logical_id" '14761) '('"_id" '"a125c17d-9907023e-fb5aade4-8dc65cb5") $25))
(let $45 (DqPhyStage '($43) (lambda '($120) (block '(
  (let $121 (WideCombiner (ToFlow (WideFromBlocks $120)) '"" $36 $37 $37 $36))
  (let $122 (Condense1 (NarrowMap $121 (lambda '($124) (AsStruct '('_yql_preagg_Count0 $124)))) (lambda '($125) (AggrCountInit (Member $125 '_yql_preagg_Count0))) (lambda '($126 $127) $14) (lambda '($128 $129) (AggrCountUpdate (Member $128 '_yql_preagg_Count0) $129))))
  (let $123 (lambda '($130) $16 $16 $18 (Just $130) $38 $20))
  (return (FromFlow (ExpandMap $122 $123)))
))) $44))
(let $46 '($21 '('"_id" '"36f4b168-c72b0467-f451ab96-196e484a") '('"_wide_channels" (StructType '('"subkey" $22)))))
(let $47 (DqPhyStage '() (lambda '() (DqPhyHashCombine (WideToBlocks (FromFlow $7)) '-1073741824 $36 $28 $29 $30)) $46))
(let $48 (DqCnHashShuffle (TDqOutput $47 '0) $34 '0 '"HashV2"))
(let $49 '('('"_logical_id" '15223) '('"_id" '"d975bd70-2dde1583-800c006e-1f4e0b61") $25))
(let $50 (DqPhyStage '($48) (lambda '($131) (block '(
  (let $132 (WideCombiner (ToFlow (WideFromBlocks $131)) '"" $36 $37 $37 $36))
  (let $133 (lambda '($138) (Just (SafeCast $138 $11))))
  (let $134 (Condense1 (NarrowMap $132 (lambda '($136) (AsStruct '('"subkey" $136)))) (lambda '($137) (IfPresent (Member $137 '"subkey") $133 $18)) (lambda '($139 $140) $14) (lambda '($141 $142) (block '(
    (let $143 (IfPresent (Member $141 '"subkey") $133 $18))
    (return (AggrAdd $143 $142))
  )))))
  (let $135 (lambda '($144) $16 $16 $18 $18 $38 (Just $144)))
  (return (FromFlow (ExpandMap $134 $135)))
))) $49))
(let $51 (DqCnParallelUnionAll (TDqOutput $27 '0)))
(let $52 (DqCnParallelUnionAll (TDqOutput $40 '0)))
(let $53 (DqCnParallelUnionAll (TDqOutput $45 '0)))
(let $54 (DqCnParallelUnionAll (TDqOutput $50 '0)))
(let $55 '($51 $52 $53 $54))
(let $56 '('('"_logical_id" '15314) '('"_id" '"50012811-aec32432-81220071-3ebfb737") $25))
(let $57 (DqPhyStage $55 (lambda '($145 $146 $147 $148) (FromFlow (Extend (ToFlow $145) (ToFlow $146) (ToFlow $147) (ToFlow $148)))) $56))
(let $58 (DqCnUnionAll (TDqOutput $57 '0)))
(let $59 (OptionalType $10))
(let $60 (OptionalType (StructType '('Avg0 $59) '('Avg1 $59) '('Count0 $11) '('Count1 $11) '('Max0 $22) '('Sum0 $17))))
(let $61 (DqPhyStage '($58) (lambda '($149) (block '(
  (let $150 (lambda '($153 $154 $155 $156 $157 $158) $153 $154 $155 $156 $157 $158))
  (let $151 (lambda '($171 $172 $173 $174 $175 $176 $177 $178 $179 $180 $181 $182) (block '(
    (let $183 (IfPresent $171 (lambda '($189) (IfPresent $177 (lambda '($190) (Just (IfPresent $189 (lambda '($191) (IfPresent $190 (lambda '($192) (Just '((AggrAdd (Nth $191 '0) (Nth $192 '0)) (AggrAdd (Nth $191 '1) (Nth $192 '1))))) $189)) $190))) $171)) $177))
    (let $184 (IfPresent $172 (lambda '($193) (IfPresent $178 (lambda '($194) (Just (IfPresent $193 (lambda '($195) (IfPresent $194 (lambda '($196) (Just '((AggrAdd (Nth $195 '0) (Nth $196 '0)) (AggrAdd (Nth $195 '1) (Nth $196 '1))))) $193)) $194))) $172)) $178))
    (let $185 (IfPresent $173 (lambda '($197) (IfPresent $179 (lambda '($198) (Just (AggrAdd $197 $198))) $173)) $179))
    (let $186 (IfPresent $174 (lambda '($199) (IfPresent $180 (lambda '($200) (Just (AggrAdd $199 $200))) $174)) $180))
    (let $187 (IfPresent $175 (lambda '($201) (IfPresent $181 (lambda '($202) (Just (AggrMax $201 $202))) $175)) $181))
    (let $188 (IfPresent $176 (lambda '($203) (IfPresent $182 (lambda '($204) (Just (AggrAdd $203 $204))) $176)) $182))
    (return $183 $184 $185 $186 $187 $188)
  ))))
  (let $152 (WideCondense1 (ToFlow $149) $150 (lambda '($159 $160 $161 $162 $163 $164 $165 $166 $167 $168 $169 $170) $14) $151))
  (return (FromFlow (Condense (NarrowMap (Take $152 $8) (lambda '($205 $206 $207 $208 $209 $210) (block '(
    (let $211 (lambda '($215) (Just (Div (Nth $215 '0) (Nth $215 '1)))))
    (let $212 (Nothing $59))
    (let $213 (IfPresent (Unwrap $205) $211 $212))
    (let $214 (IfPresent (Unwrap $206) $211 $212))
    (return (AsStruct '('Avg0 $213) '('Avg1 $214) '('Count0 (Unwrap $207)) '('Count1 (Unwrap $208)) '('Max0 (Unwrap $209)) '('Sum0 (Unwrap $210))))
  )))) (Nothing $60) (lambda '($216 $217) $14) (lambda '($218 $219) (Just $218)))))
))) '('('"_logical_id" '15441) '('"_id" '"8b9ddb6d-40076971-1ec63358-3afae8df"))))
(let $62 '($27 $33 $40 $42 $45 $47 $50 $57 $61))
(let $63 (DqCnValue (TDqOutput $61 '0)))
(let $64 (KqpPhysicalTx $62 '($63) '() '('('"type" '"compute"))))
(let $65 '"%kqp%tx_result_binding_0_0")
(let $66 '('('"_logical_id" '15605) '('"_id" '"49a916d2-750857cb-ddc53290-c07aff6d") '('"_partition_mode" '"single")))
(let $67 (DqPhyStage '() (lambda '() (block '(
  (let $220 %kqp%tx_result_binding_0_0)
  (let $221 (Uint64 '0))
  (return (Iterator (AsList (AsStruct '('"column0" (Coalesce (Member $220 'Count0) $221)) '('"column1" (Member $220 'Max0)) '('"column2" (Member $220 'Sum0)) '('"column3" (Member $220 'Avg0)) '('"column4" (Coalesce (Member $220 'Count1) $221)) '('"column5" (Member $220 'Avg1))))))
))) $66))
(let $68 '('"column0" '"column1" '"column2" '"column3" '"column4" '"column5"))
(let $69 (DqCnResult (TDqOutput $67 '0) $68))
(let $70 (KqpTxResultBinding $60 '0 '0))
(let $71 (KqpPhysicalTx '($67) '($69) '('($65 $70)) '('('"type" '"generic"))))
(return (KqpPhysicalQuery '($64 $71) '((KqpTxResultBinding (ListType (StructType '('"column0" $11) '('"column1" $22) '('"column2" $17) '('"column3" $59) '('"column4" $11) '('"column5" $59))) '1 '0)) '('('"type" '"query"))))
)
