(
(let $1 (DataSource '"yt" '"/Root/plato"))
(let $2 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
(let $3 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $2)))
(let $4 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
(let $5 (YtStat '('Id '"Input") '('RecordsCount '"10") '('DataSize '"390") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
(let $6 (YtTable '"Input" $3 $4 $5 '() (Void) (Void) '"/Root/plato"))
(let $7 (OptionalType (DataType 'Int32)))
(let $8 (ResourceType '"Stat.TDigestResource"))
(let $9 '($8))
(let $10 (DataType 'Double))
(let $11 '($10))
(let $12 (OptionalType $10))
(let $13 '($12))
(let $14 (CallableType '('2) $9 $11 $13 $13))
(let $15 (Udf '"Stat.TDigest_Create" (Void) (VoidType) '"" $14 (VoidType) '"" '()))
(let $16 (DependsOn (Uint32 '0)))
(let $17 (OptionalType $8))
(let $18 (Nothing $17))
(let $19 (CallableType '() $9 $9 $11))
(let $20 '('('"strict")))
(let $21 (Udf '"Stat.TDigest_AddValue" (Void) (VoidType) '"" $19 (VoidType) '"" $20))
(let $22 (DataType 'String))
(let $23 '($22))
(let $24 (CallableType '() $23 $9))
(let $25 (Udf '"Stat.TDigest_Serialize" (Void) (VoidType) '"" $24 (VoidType) '"" $20))
(let $26 (OptionalType $22))
(let $27 '('_yql_agg_0 $26))
(let $28 '('"key" $22))
(let $29 '('('"_logical_id" '10568) '('"_id" '"9e61f721-f1c6f274-481c274b-6aa9a7ae") '('"_wide_channels" (StructType $27 $28))))
(let $30 (DqPhyStage '() (lambda '() (block '(
  (let $79 (YtReadTable! world $1 '((YtSection '((YtPath $6 '('"key" '"value") (Void) (Void) (Void))) '()))))
  (let $80 (lambda '($87) (Just (NamedApply $15 '((Convert $87 $10)) (AsStruct) $16))))
  (let $81 (lambda '($96 $97) (block '(
    (let $98 (IfPresent $97 (lambda '($99) (Just (Apply $25 $99))) (Nothing $26)))
    (return $98 $96)
  ))))
  (return (DqPhyHashCombine (FromFlow (DqReadWideWrap $79 '())) '-1073741824 (lambda '($82 $83) $82) (lambda '($84 $85 $86) (IfPresent (SafeCast $86 $7) $80 $18)) (lambda '($88 $89 $90 $91) (block '(
    (let $92 (SafeCast $90 $7))
    (let $93 (IfPresent $92 $80 $18))
    (return (IfPresent $91 (lambda '($94) (IfPresent $92 (lambda '($95) (Just (NamedApply $21 '($94 (Convert $95 $10)) (AsStruct) $16))) (Just $94))) $93))
  ))) $81))
))) $29))
(let $31 (DqCnHashShuffle (TDqOutput $30 '0) '('1) '0 '"HashV2"))
(let $32 (CallableType '() $9 $23))
(let $33 (Udf '"Stat.TDigest_Deserialize" (Void) (VoidType) '"" $32 (VoidType) '"" '()))
(let $34 (CallableType '() $9 $9 $9))
(let $35 (Udf '"Stat.TDigest_Merge" (Void) (VoidType) '"" $34 (VoidType) '"" $20))
(let $36 (CallableType '() $11 $9 $11))
(let $37 (Udf '"Stat.TDigest_GetPercentile" (Void) (VoidType) '"" $36 (VoidType) '"" $20))
(let $38 (Double '0.5))
(let $39 (Double '"0.2"))
(let $40 (Double '"0.4"))
(let $41 (Double '"0.6"))
(let $42 (TupleType $10 $10 $10))
(let $43 (StructType '('"p20" $10) '('"p40" $10) '('"p60" $10)))
(let $44 (ListType $10))
(let $45 (OptionalType (TupleType $10 $42 $43 $44)))
(let $46 '('"med" $12))
(let $47 (OptionalType $44))
(let $48 '('"plist" $47))
(let $49 (OptionalType $43))
(let $50 '('"pstruct" $49))
(let $51 (OptionalType $42))
(let $52 '('"ptuple" $51))
(let $53 (StructType $28 $46 $48 $50 $52))
(let $54 '('('"_logical_id" '11363) '('"_id" '"c97740e0-68caa43c-64d328b2-4e09e67f") '('"_wide_channels" $53)))
(let $55 (DqPhyStage '($31) (lambda '($100) (block '(
  (let $101 (lambda '($110) (Just (Apply $33 $110))))
  (let $102 (lambda '($118 $119) (block '(
    (let $120 (IfPresent $119 (lambda '($121) (block '(
      (let $122 (Apply $37 $121 $38))
      (let $123 (Apply $37 $121 $39))
      (let $124 (Apply $37 $121 $40))
      (let $125 (Apply $37 $121 $41))
      (let $126 '($123 $124 $125))
      (let $127 (AsStruct '('"p20" $123) '('"p40" $124) '('"p60" $125)))
      (let $128 (AsList $123 $124 $125))
      (return (Just '($122 $126 $127 $128)))
    ))) (Nothing $45)))
    (return (Nth $120 '0) (Nth $120 '1) (Nth $120 '2) (Nth $120 '3) $118)
  ))))
  (let $103 (WideCombiner (ToFlow $100) '"" (lambda '($105 $106) $106) (lambda '($107 $108 $109) (IfPresent $108 $101 $18)) (lambda '($111 $112 $113 $114) (IfPresent $112 (lambda '($115) (block '(
    (let $116 (IfPresent $112 $101 $18))
    (return (IfPresent $114 (lambda '($117) (Just (Apply $35 (Apply $33 $115) $117))) $116))
  ))) $114)) $102))
  (let $104 (lambda '($129 $130 $131 $132 $133) $133 $129 $132 $131 $130))
  (return (FromFlow (WideMap (WideSort $103 '('('4 (Bool 'true)))) $104)))
))) $54))
(let $56 (DqCnMerge (TDqOutput $55 '0) '('('0 '"Asc"))))
(let $57 (DqPhyStage '($56) (lambda '($134) (FromFlow (NarrowMap (ToFlow $134) (lambda '($135 $136 $137 $138 $139) (AsStruct '('"key" $135) '('"med" $136) '('"plist" $137) '('"pstruct" $138) '('"ptuple" $139)))))) '('('"_logical_id" '11375) '('"_id" '"dc59210a-19e85089-183e794d-7e526b56"))))
(let $58 '($30 $55 $57))
(let $59 '('"key" '"med" '"ptuple" '"pstruct" '"plist"))
(let $60 (DqCnResult (TDqOutput $57 '0) $59))
(let $61 '('('"type" '"generic")))
(let $62 (KqpPhysicalTx $58 '($60) '() $61))
(let $63 (Nothing $17))
(let $64 (Bool 'false))
(let $65 '('('"_logical_id" '11556) '('"_id" '"5adf4fa2-34d5d01d-763ded88-147dcac1") '('"_wide_channels" (StructType $27))))
(let $66 (DqPhyStage '() (lambda '() (block '(
  (let $140 (YtReadTable! world $1 '((YtSection '((YtPath $6 '('"value") (Void) (Void) (Void))) '()))))
  (let $141 (lambda '($145) (Just (NamedApply $15 '((Convert $145 $10)) (AsStruct) $16))))
  (let $142 (Condense1 (NarrowMap (DqReadWideWrap $140 '()) (lambda '($143) (AsStruct '('"value" $143)))) (lambda '($144) (IfPresent (SafeCast (Member $144 '"value") $7) $141 $63)) (lambda '($146 $147) $64) (lambda '($148 $149) (block '(
    (let $150 (SafeCast (Member $148 '"value") $7))
    (let $151 (IfPresent $150 $141 $63))
    (return (IfPresent $149 (lambda '($152) (IfPresent $150 (lambda '($153) (Just (NamedApply $21 '($152 (Convert $153 $10)) (AsStruct) $16))) (Just $152))) $151))
  )))))
  (return (FromFlow (ExpandMap $142 (lambda '($154) (IfPresent $154 (lambda '($155) (Just (Apply $25 $155))) (Nothing $26))))))
))) $65))
(let $67 (DqCnUnionAll (TDqOutput $66 '0)))
(let $68 (StructType '('Median0 $12) '('Percentile0 $51) '('Percentile1 $49) '('Percentile2 $47)))
(let $69 '('('"_logical_id" '12281) '('"_id" '"cc8d6325-9a8ecdd3-80285189-6e2cf4b0") '('"_partition_mode" '"aggregate") '('"_wide_channels" $68)))
(let $70 (DqPhyStage '($67) (lambda '($156) (block '(
  (let $157 (lambda '($161) (Just (Apply $33 $161))))
  (let $158 (WideCondense1 (ToFlow $156) (lambda '($160) (IfPresent $160 $157 $63)) (lambda '($162 $163) $64) (lambda '($164 $165) (IfPresent $164 (lambda '($166) (block '(
    (let $167 (IfPresent $164 $157 $63))
    (return (IfPresent $165 (lambda '($168) (Just (Apply $35 (Apply $33 $166) $168))) $167))
  ))) $165))))
  (let $159 (lambda '($169) (block '(
    (let $170 (IfPresent $169 (lambda '($171) (block '(
      (let $172 (Apply $37 $171 $38))
      (let $173 (Apply $37 $171 $39))
      (let $174 (Apply $37 $171 $40))
      (let $175 (Apply $37 $171 $41))
      (let $176 '($173 $174 $175))
      (let $177 (AsStruct '('"p20" $173) '('"p40" $174) '('"p60" $175)))
      (let $178 (AsList $173 $174 $175))
      (return (Just '($172 $176 $177 $178)))
    ))) (Nothing $45)))
    (return (Nth $170 '0) (Nth $170 '1) (Nth $170 '2) (Nth $170 '3))
  ))))
  (return (FromFlow (WideMap $158 $159)))
))) $69))
(let $71 (DqCnUnionAll (TDqOutput $70 '0)))
(let $72 (DqPhyStage '($71) (lambda '($179) (block '(
  (let $180 (Condense (NarrowMap (ToFlow $179) (lambda '($181 $182 $183 $184) (AsStruct '('Median0 $181) '('Percentile0 $182) '('Percentile1 $183) '('Percentile2 $184)))) (List (ListType $68)) (lambda '($185 $186) $64) (lambda '($187 $188) (AsList $187))))
  (return (FromFlow (Map $180 (lambda '($189) (block '(
    (let $190 (ToOptional $189))
    (return (AsStruct '('"med" (Member $190 'Median0)) '('"plist" (Member $190 'Percentile2)) '('"pstruct" (Member $190 'Percentile1)) '('"ptuple" (Member $190 'Percentile0))))
  ))))))
))) '('('"_logical_id" '12343) '('"_id" '"4436b6f2-8b16bdd0-3dcc8cdb-d1cb40ce"))))
(let $73 '($66 $70 $72))
(let $74 '('"med" '"ptuple" '"pstruct" '"plist"))
(let $75 (DqCnResult (TDqOutput $72 '0) $74))
(let $76 (KqpPhysicalTx $73 '($75) '() $61))
(let $77 (KqpTxResultBinding (ListType $53) '0 '0))
(let $78 (KqpTxResultBinding (ListType (StructType $46 $48 $50 $52)) '1 '0))
(return (KqpPhysicalQuery '($62 $76) '($77 $78) '('('"type" '"query"))))
)
