(
(let $1 (DataType 'Double))
(let $2 (OptionalType $1))
(let $3 (OptionalType (TupleType $1 (DataType 'Uint64))))
(let $4 (Bool 'false))
(let $5 '('('"_logical_id" '2427) '('"_id" '"59660f8a-fafa54bf-bb288e9e-2742061a") '('"_wide_channels" (StructType '('_yql_agg_0 $3)))))
(let $6 (DqPhyStage '() (lambda '() (block '(
  (let $15 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $16 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $15)))
  (let $17 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $18 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $19 (YtTable '"Input" $16 $17 $18 '() (Void) (Void) '"/Root/plato"))
  (let $20 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $19 '() (Void) (Void))) '()))))
  (let $21 (SafeCast (String '"key") $2))
  (let $22 (IfPresent $21 (lambda '($25) (Just '($25 (Uint64 '1)))) (Nothing $3)))
  (let $23 (Condense1 (NarrowMap (DqReadWideWrap $20 '()) (lambda '() (AsStruct))) (lambda '($24) $22) (lambda '($26 $27) $4) (lambda '($28 $29) (IfPresent $29 (lambda '($30) (IfPresent $21 (lambda '($31) (Just '((AggrAdd (Nth $30 '0) $31) (Inc (Nth $30 '1))))) (Just $30))) $22))))
  (return (FromFlow (ExpandMap $23 (lambda '($32) $32))))
))) $5))
(let $7 (DqCnUnionAll (TDqOutput $6 '0)))
(let $8 (StructType '('Avg0 $2)))
(let $9 '('('"_logical_id" '2498) '('"_id" '"f15ab69e-8ee5d856-ff6dcf9e-9dd48250") '('"_partition_mode" '"aggregate") '('"_wide_channels" $8)))
(let $10 (DqPhyStage '($7) (lambda '($33) (block '(
  (let $34 (Condense1 (NarrowMap (ToFlow $33) (lambda '($35) (AsStruct '('_yql_agg_0 $35)))) (lambda '($36) (Member $36 '_yql_agg_0)) (lambda '($37 $38) $4) (lambda '($39 $40) (block '(
    (let $41 (Member $39 '_yql_agg_0))
    (return (IfPresent $41 (lambda '($42) (IfPresent $40 (lambda '($43) (Just '((AggrAdd (Nth $42 '0) (Nth $43 '0)) (AggrAdd (Nth $42 '1) (Nth $43 '1))))) $41)) $40))
  )))))
  (return (FromFlow (ExpandMap $34 (lambda '($44) (IfPresent $44 (lambda '($45) (Just (Div (Nth $45 '0) (Nth $45 '1)))) (Nothing $2))))))
))) $9))
(let $11 (DqCnUnionAll (TDqOutput $10 '0)))
(let $12 (DqPhyStage '($11) (lambda '($46) (block '(
  (let $47 (Condense (NarrowMap (ToFlow $46) (lambda '($48) (AsStruct '('Avg0 $48)))) (List (ListType $8)) (lambda '($49 $50) $4) (lambda '($51 $52) (AsList $51))))
  (return (FromFlow (Map $47 (lambda '($53) (AsStruct '('"column0" (Member (ToOptional $53) 'Avg0)))))))
))) '('('"_logical_id" '2664) '('"_id" '"e7902f97-46f3a9b0-1f609d6a-dfdf2957"))))
(let $13 '($6 $10 $12))
(let $14 (DqCnResult (TDqOutput $12 '0) '('"column0")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $13 '($14) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType (StructType '('"column0" $2))) '0 '0)) '('('"type" '"query"))))
)
