(
(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 '('"key" '"subkey") (Void) (Void))) '()))))
(let $7 (DqReadWideWrap $6 '()))
(let $8 (lambda '($72 $73) $72))
(let $9 (lambda '($78) (block '(
  (let $79 (Uint64 '1))
  (return (Just '((Convert $78 'Double) $79)))
))))
(let $10 (DataType 'Double))
(let $11 (DataType 'Uint64))
(let $12 (OptionalType (TupleType $10 $11)))
(let $13 (Nothing $12))
(let $14 (OptionalType $12))
(let $15 (Nothing $14))
(let $16 (OptionalType $11))
(let $17 (Nothing $16))
(let $18 (OptionalType $16))
(let $19 (Nothing $18))
(let $20 '('"_logical_id" '15253))
(let $21 (DataType 'Uint32))
(let $22 (OptionalType $21))
(let $23 (OptionalType $22))
(let $24 '('"key" $21))
(let $25 (StructType '('_yql_agg_0 $14) '('_yql_agg_1 $14) '('_yql_agg_2 $16) '('_yql_agg_3 $16) '('_yql_agg_4 $23) '('_yql_agg_5 $18) $24))
(let $26 '('"_wide_channels" $25))
(let $27 '($20 '('"_id" '"28d7ca05-e4633cf3-9a32fd9-b319b9c9") $26))
(let $28 (DqPhyStage '() (lambda '() (block '(
  (let $68 (Uint64 '1))
  (let $69 (lambda '($74 $75 $76) (block '(
    (let $77 (IfPresent $76 $9 $13))
    (return $77 $68 $76)
  ))))
  (let $70 (lambda '($80 $81 $82 $83 $84 $85) (block '(
    (let $86 (IfPresent $82 $9 $13))
    (let $87 (IfPresent $83 (lambda '($88) (IfPresent $82 (lambda '($89) (Just '((AggrAdd (Nth $88 '0) (Convert $89 'Double)) (Inc (Nth $88 '1))))) (Just $88))) $86))
    (return $87 (AggrAdd $84 $68) (AggrMax $82 $85))
  ))))
  (let $71 (lambda '($90 $91 $92 $93) (Just $91) $15 (Just $92) $17 (Just $93) $19 $90))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow $7)) '-1073741824 $8 $69 $70 $71))
))) $27))
(let $29 (lambda '() (block '(
  (let $94 (lambda '($98 $99) (/ $99 (Uint32 '"2")) $98))
  (let $95 (lambda '($100 $101 $102 $103) $100 $101))
  (let $96 (lambda '($104 $105 $106 $107 $108 $109) $108 $109))
  (let $97 (lambda '($110 $111 $112 $113) $112 $113))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow $7)) '-1073741824 $94 $95 $96 $97))
))))
(let $30 '($20 '('"_id" '"7c4079c7-42cd5bbd-fa3b3b13-1a2ebfdd") '('"_wide_channels" (StructType '('_yql_preagg_Avg0 $22) $24))))
(let $31 (DqPhyStage '() $29 $30))
(let $32 '('0 '1))
(let $33 (DqCnHashShuffle (TDqOutput $31 '0) $32 '0 '"HashV2"))
(let $34 (lambda '($116 $117) $116 $117))
(let $35 (lambda '($118 $119 $120 $121)))
(let $36 (lambda '($122 $123) $123))
(let $37 (Nothing $23))
(let $38 '('('"_logical_id" '14297) '('"_id" '"1df70816-fe72a1f9-5025cb69-62c67509") $26))
(let $39 (DqPhyStage '($33) (lambda '($114) (block '(
  (let $115 (lambda '($134 $135) $15 (Just $135) $17 $17 $37 $19 $134))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (WideCombiner (ToFlow (WideFromBlocks $114)) '"" $34 $35 $35 $34))) '-1073741824 $36 (lambda '($124 $125 $126) (IfPresent $125 $9 $13)) (lambda '($127 $128 $129 $130) (block '(
    (let $131 (IfPresent $128 $9 $13))
    (return (IfPresent $130 (lambda '($132) (IfPresent $128 (lambda '($133) (Just '((AggrAdd (Nth $132 '0) (Convert $133 'Double)) (Inc (Nth $132 '1))))) (Just $132))) $131))
  ))) $115))
))) $38))
(let $40 '($20 '('"_id" '"6ac681f5-a913306b-d5d02bc2-89fa6a5b") '('"_wide_channels" (StructType '('_yql_preagg_Count0 $22) $24))))
(let $41 (DqPhyStage '() $29 $40))
(let $42 (DqCnHashShuffle (TDqOutput $41 '0) $32 '0 '"HashV2"))
(let $43 '('('"_logical_id" '15042) '('"_id" '"d03d63c5-93445147-e53d351c-ee69d197") $26))
(let $44 (DqPhyStage '($42) (lambda '($136) (block '(
  (let $137 (lambda '($145 $146) $15 $15 $17 (Just $146) $37 $19 $145))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (WideCombiner (ToFlow (WideFromBlocks $136)) '"" $34 $35 $35 $34))) '-1073741824 $36 (lambda '($138 $139 $140) (AggrCountInit $139)) (lambda '($141 $142 $143 $144) (AggrCountUpdate $142 $144)) $137))
))) $43))
(let $45 (lambda '($150 $151) $150 $151))
(let $46 '($20 '('"_id" '"87c431ad-72eedb53-d025926f-adf68d65") '('"_wide_channels" (StructType $24 '('"subkey" $22)))))
(let $47 (DqPhyStage '() (lambda '() (block '(
  (let $147 (lambda '($152 $153 $154 $155) $152 $153))
  (let $148 (lambda '($156 $157 $158 $159 $160 $161) $160 $161))
  (let $149 (lambda '($162 $163 $164 $165) $164 $165))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow $7)) '-1073741824 $45 $147 $148 $149))
))) $46))
(let $48 (DqCnHashShuffle (TDqOutput $47 '0) $32 '0 '"HashV2"))
(let $49 '('('"_logical_id" '15438) '('"_id" '"5e54b2cc-c51650c9-3ce63b4f-affb68b1") $26))
(let $50 (DqPhyStage '($48) (lambda '($166) (block '(
  (let $167 (lambda '($170 $171 $172 $173)))
  (let $168 (lambda '($177) (Just (SafeCast $177 $11))))
  (let $169 (lambda '($183 $184) $15 $15 $17 $17 $37 (Just $184) $183))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (WideCombiner (ToFlow (WideFromBlocks $166)) '"" $45 $167 $167 $45))) '-1073741824 $8 (lambda '($174 $175 $176) (IfPresent $176 $168 $17)) (lambda '($178 $179 $180 $181) (block '(
    (let $182 (IfPresent $180 $168 $17))
    (return (AggrAdd $182 $181))
  ))) $169))
))) $49))
(let $51 (DqCnParallelUnionAll (TDqOutput $28 '0)))
(let $52 (DqCnParallelUnionAll (TDqOutput $39 '0)))
(let $53 (DqCnParallelUnionAll (TDqOutput $44 '0)))
(let $54 (DqCnParallelUnionAll (TDqOutput $50 '0)))
(let $55 '($51 $52 $53 $54))
(let $56 '('('"_logical_id" '15511) '('"_id" '"2d6b2e11-6525406a-16dfb2fe-b8600ea6") $26))
(let $57 (DqPhyStage $55 (lambda '($185 $186 $187 $188) (FromFlow (Extend (ToFlow (WideFromBlocks $185)) (ToFlow (WideFromBlocks $186)) (ToFlow (WideFromBlocks $187)) (ToFlow (WideFromBlocks $188))))) $56))
(let $58 (DqCnHashShuffle (TDqOutput $57 '0) '('6) '0 '"HashV2"))
(let $59 (OptionalType $10))
(let $60 (StructType '('"column1" $11) '('"column2" $22) '('"column3" $16) '('"column4" $59) '('"column5" $11) '('"column6" $59) $24))
(let $61 '('('"_logical_id" '15597) '('"_id" '"401163d0-59f0b38c-72e468b2-213d370b") '('"_wide_channels" $60)))
(let $62 (DqPhyStage '($58) (lambda '($189) (block '(
  (let $190 (lambda '($202 $203 $204 $205 $206 $207 $208 $209) $203 $204 $205 $206 $207 $208))
  (let $191 (lambda '($210 $211 $212 $213 $214 $215 $216 $217 $218 $219 $220 $221 $222 $223) (block '(
    (let $224 (IfPresent $211 (lambda '($230) (IfPresent $218 (lambda '($231) (Just (IfPresent $230 (lambda '($232) (IfPresent $231 (lambda '($233) (Just '((AggrAdd (Nth $232 '0) (Nth $233 '0)) (AggrAdd (Nth $232 '1) (Nth $233 '1))))) $230)) $231))) $211)) $218))
    (let $225 (IfPresent $212 (lambda '($234) (IfPresent $219 (lambda '($235) (Just (IfPresent $234 (lambda '($236) (IfPresent $235 (lambda '($237) (Just '((AggrAdd (Nth $236 '0) (Nth $237 '0)) (AggrAdd (Nth $236 '1) (Nth $237 '1))))) $234)) $235))) $212)) $219))
    (let $226 (IfPresent $213 (lambda '($238) (IfPresent $220 (lambda '($239) (Just (AggrAdd $238 $239))) $213)) $220))
    (let $227 (IfPresent $214 (lambda '($240) (IfPresent $221 (lambda '($241) (Just (AggrAdd $240 $241))) $214)) $221))
    (let $228 (IfPresent $215 (lambda '($242) (IfPresent $222 (lambda '($243) (Just (AggrMax $242 $243))) $215)) $222))
    (let $229 (IfPresent $216 (lambda '($244) (IfPresent $223 (lambda '($245) (Just (AggrAdd $244 $245))) $216)) $223))
    (return $224 $225 $226 $227 $228 $229)
  ))))
  (let $192 (lambda '($246 $247 $248 $249 $250 $251 $252) (block '(
    (let $253 (lambda '($257) (Just (Div (Nth $257 '0) (Nth $257 '1)))))
    (let $254 (Nothing $59))
    (let $255 (IfPresent (Unwrap $247) $253 $254))
    (let $256 (IfPresent (Unwrap $248) $253 $254))
    (return $255 $256 (Unwrap $249) (Unwrap $250) (Unwrap $251) (Unwrap $252) $246)
  ))))
  (let $193 (WideCombiner (ToFlow $189) '"" (lambda '($195 $196 $197 $198 $199 $200 $201) $201) $190 $191 $192))
  (let $194 (lambda '($258 $259 $260 $261 $262 $263 $264) $260 $262 $263 $258 $261 $259 $264))
  (return (FromFlow (WideMap (WideSort $193 '('('6 (Bool 'true)))) $194)))
))) $61))
(let $63 (DqCnMerge (TDqOutput $62 '0) '('('6 '"Asc"))))
(let $64 (DqPhyStage '($63) (lambda '($265) (FromFlow (NarrowMap (ToFlow $265) (lambda '($266 $267 $268 $269 $270 $271 $272) (AsStruct '('"column1" $266) '('"column2" $267) '('"column3" $268) '('"column4" $269) '('"column5" $270) '('"column6" $271) '('"key" $272)))))) '('('"_logical_id" '15609) '('"_id" '"4529f34f-9404f742-77291721-48a86d8e"))))
(let $65 '($28 $31 $39 $41 $44 $47 $50 $57 $62 $64))
(let $66 '('"key" '"column1" '"column2" '"column3" '"column4" '"column5" '"column6"))
(let $67 (DqCnResult (TDqOutput $64 '0) $66))
(return (KqpPhysicalQuery '((KqpPhysicalTx $65 '($67) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $60) '0 '0)) '('('"type" '"query"))))
)
