(
(let $1 '('"key" '"subkey" '"value"))
(let $2 (DataType 'Double))
(let $3 (OptionalType (TupleType $2 (DataType 'Uint64))))
(let $4 (DataType 'Int64))
(let $5 (OptionalType $4))
(let $6 (DataType 'String))
(let $7 '('"value" $6))
(let $8 (StructType '('_yql_agg_0 $3) '('_yql_agg_1 $5) $7))
(let $9 '('('"_logical_id" '3473) '('"_id" '"71986fd9-719c5e87-4ee80be-d12c77c7") '('"_wide_channels" $8)))
(let $10 (DqPhyStage '() (lambda '() (block '(
  (let $21 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $22 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $21)))
  (let $23 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('HasRLS '0) '('Attrs '('('"native_strict_schema" '"false")))))
  (let $24 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"167") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $25 (YtTable '"Input" $22 $23 $24 '() (Void) (Void) '"/Root/plato"))
  (let $26 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $25 $1 (Void) (Void) (Void))) '()))))
  (let $27 (OptionalType (DataType 'Int32)))
  (let $28 (lambda '($44) (Just '((Convert $44 'Double) (Uint64 '1)))))
  (let $29 (Nothing $3))
  (let $30 (lambda '($45) (Just (SafeCast $45 $4))))
  (let $31 (Nothing $5))
  (let $32 (lambda '($38 $39 $40 $41) (block '(
    (let $42 (IfPresent (SafeCast $39 $27) $28 $29))
    (let $43 (IfPresent (SafeCast $40 $27) $30 $31))
    (return $42 $43)
  ))))
  (let $33 (lambda '($46 $47 $48 $49 $50 $51) (block '(
    (let $52 (SafeCast $47 $27))
    (let $53 (IfPresent $52 $28 $29))
    (let $54 (IfPresent $50 (lambda '($56) (IfPresent $52 (lambda '($57) (Just '((AggrAdd (Nth $56 '0) (Convert $57 'Double)) (Inc (Nth $56 '1))))) (Just $56))) $53))
    (let $55 (IfPresent (SafeCast $48 $27) $30 $31))
    (return $54 (AggrAdd $55 $51))
  ))))
  (let $34 (lambda '($58 $59 $60) $59 $60 $58))
  (return (FromFlow (DqPhyHashCombine (DqReadWideWrap $26 '()) '-1073741824 (lambda '($35 $36 $37) $37) $32 $33 $34)))
))) $9))
(let $11 (DqCnHashShuffle (TDqOutput $10 '0) '('"2") '0 '"HashV2"))
(let $12 (OptionalType $2))
(let $13 (OptionalType $6))
(let $14 (StructType '('"key" $12) '('"subkey" $13) $7))
(let $15 '('('"_logical_id" '3773) '('"_id" '"526073-5e44b536-114bf53b-a131ba1e") '('"_wide_channels" $14)))
(let $16 (DqPhyStage '($11) (lambda '($61) (block '(
  (let $62 (NarrowSqueezeToDict (ToFlow $61) (lambda '($66 $67 $68) $68) (lambda '($69 $70 $71) (AsStruct '('_yql_agg_0 $69) '('_yql_agg_1 $70) '('"value" $71))) '('Auto 'Many)))
  (let $63 (Condense1 (OrderedFlatMap $62 (lambda '($72) (OrderedFlatMap (DictPayloads $72) (lambda '($73) $73)))) (lambda '($74) $74) (lambda '($75 $76) (AggrNotEquals (Member $75 '"value") (Member $76 '"value"))) (lambda '($77 $78) (block '(
    (let $79 (Member $77 '_yql_agg_0))
    (let $80 (Member $78 '_yql_agg_0))
    (let $81 (IfPresent $79 (lambda '($82) (IfPresent $80 (lambda '($83) (Just '((AggrAdd (Nth $82 '0) (Nth $83 '0)) (AggrAdd (Nth $82 '1) (Nth $83 '1))))) $79)) $80))
    (return (AsStruct '('_yql_agg_0 $81) '('_yql_agg_1 (AggrAdd (Member $77 '_yql_agg_1) (Member $78 '_yql_agg_1))) '('"value" (Member $78 '"value"))))
  )))))
  (let $64 (Sort (Map $63 (lambda '($84) (block '(
    (let $85 (IfPresent (Member $84 '_yql_agg_0) (lambda '($87) (Just (Div (Nth $87 '0) (Nth $87 '1)))) (Nothing $12)))
    (let $86 (IfPresent (Member $84 '_yql_agg_1) (lambda '($88) (Just (SafeCast $88 $6))) (Nothing $13)))
    (return (AsStruct '('"key" (+ $85 (Double '"0.3"))) '('"subkey" $86) '('"value" (Member $84 '"value"))))
  )))) (Bool 'true) (lambda '($89) (Member $89 '"value"))))
  (let $65 (lambda '($90) (Member $90 '"key") (Member $90 '"subkey") (Member $90 '"value")))
  (return (FromFlow (ExpandMap $64 $65)))
))) $15))
(let $17 (DqCnMerge (TDqOutput $16 '0) '('('"2" '"Asc"))))
(let $18 (DqPhyStage '($17) (lambda '($91) (FromFlow (NarrowMap (ToFlow $91) (lambda '($92 $93 $94) (AsStruct '('"key" $92) '('"subkey" $93) '('"value" $94)))))) '('('"_logical_id" '3785) '('"_id" '"f6798a10-57931933-1b010b35-5b6dd636"))))
(let $19 '($10 $16 $18))
(let $20 (DqCnResult (TDqOutput $18 '0) $1))
(return (KqpPhysicalQuery '((KqpPhysicalTx $19 '($20) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $14) '0 '0)) '('('"type" '"query"))))
)
