(
(let $1 (ResourceType '"Stat.TDigestResource"))
(let $2 '($1))
(let $3 (DataType 'Double))
(let $4 '($3))
(let $5 (OptionalType $3))
(let $6 (Nothing (OptionalType $1)))
(let $7 '('('"strict")))
(let $8 (DataType 'String))
(let $9 '($8))
(let $10 (OptionalType $8))
(let $11 '('"a" $8))
(let $12 '('('"_logical_id" '6472) '('"_id" '"abeb1d69-f9ca3823-e6becf15-10904090") '('"_wide_channels" (StructType '('_yql_agg_0 $10) $11))))
(let $13 (DqPhyStage '() (lambda '() (block '(
  (let $21 '@@["StructType";[["a";["DataType";"String"]];["b";["DataType";"String"]];["c";["DataType";"String"]];["d";["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) '('Attrs '('('"native_strict_schema" '"false")))))
  (let $24 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"140") '('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 '('"a" '"c") (Void) (Void))) '()))))
  (let $27 (OptionalType (DataType 'Int32)))
  (let $28 (DependsOn (Uint32 '0)))
  (let $29 (lambda '($36) (block '(
    (let $37 '($5))
    (let $38 (CallableType '('"2") $2 $4 $37 $37))
    (let $39 (Udf '"Stat.TDigest_Create" (Void) (VoidType) '"" $38 (VoidType) '"" '()))
    (return (Just (NamedApply $39 '((Convert $36 $3)) (AsStruct) $28)))
  ))))
  (let $30 (lambda '($50 $51) (block '(
    (let $52 (IfPresent $51 (lambda '($53) (block '(
      (let $54 (CallableType '() $9 $2))
      (let $55 (Udf '"Stat.TDigest_Serialize" (Void) (VoidType) '"" $54 (VoidType) '"" $7))
      (return (Just (Apply $55 $53)))
    ))) (Nothing $10)))
    (return $52 $50)
  ))))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (DqReadWideWrap $26 '()))) '-1073741824 (lambda '($31 $32) $31) (lambda '($33 $34 $35) (IfPresent (SafeCast $35 $27) $29 $6)) (lambda '($40 $41 $42 $43) (block '(
    (let $44 (SafeCast $42 $27))
    (let $45 (IfPresent $44 $29 $6))
    (return (IfPresent $43 (lambda '($46) (IfPresent $44 (lambda '($47) (block '(
      (let $48 (CallableType '() $2 $2 $4))
      (let $49 (Udf '"Stat.TDigest_AddValue" (Void) (VoidType) '"" $48 (VoidType) '"" $7))
      (return (Just (NamedApply $49 '($46 (Convert $47 $3)) (AsStruct) $28)))
    ))) (Just $46))) $45))
  ))) $30))
))) $12))
(let $14 (DqCnHashShuffle (TDqOutput $13 '0) '('1) '0 '"HashV2"))
(let $15 '('('"_logical_id" '7160) '('"_id" '"3ee09ad2-c1a6d5cf-609ae35e-a499697f") '('"_partition_mode" '"aggregate")))
(let $16 (DqPhyStage '($14) (lambda '($56) (block '(
  (let $57 (CallableType '() $2 $9))
  (let $58 (Udf '"Stat.TDigest_Deserialize" (Void) (VoidType) '"" $57 (VoidType) '"" '()))
  (let $59 (lambda '($67) (Just (Apply $58 $67))))
  (let $60 (lambda '($77 $78) (block '(
    (let $79 (IfPresent $78 (lambda '($80) (block '(
      (let $81 (CallableType '() $4 $2 $4))
      (let $82 (Udf '"Stat.TDigest_GetPercentile" (Void) (VoidType) '"" $81 (VoidType) '"" $7))
      (return (Just (Apply $82 $80 (Double '0.5))))
    ))) (Nothing $5)))
    (return $79 $77)
  ))))
  (let $61 (WideCombiner (ToFlow (WideFromBlocks $56)) '"" (lambda '($62 $63) $63) (lambda '($64 $65 $66) (IfPresent $65 $59 $6)) (lambda '($68 $69 $70 $71) (IfPresent $69 (lambda '($72) (block '(
    (let $73 (IfPresent $69 $59 $6))
    (return (IfPresent $71 (lambda '($74) (block '(
      (let $75 (CallableType '() $2 $2 $2))
      (let $76 (Udf '"Stat.TDigest_Merge" (Void) (VoidType) '"" $75 (VoidType) '"" $7))
      (return (Just (Apply $76 (Apply $58 $72) $74)))
    ))) $73))
  ))) $71)) $60))
  (return (FromFlow (NarrowMap $61 (lambda '($83 $84) (AsStruct '('"a" $84) '('"cc1" $83))))))
))) $15))
(let $17 (DqCnUnionAll (TDqOutput $16 '0)))
(let $18 (DqPhyStage '($17) (lambda '($85) $85) '('('"_logical_id" '7346) '('"_id" '"3472833-df7895c3-1b5e8991-b2fb690"))))
(let $19 '($13 $16 $18))
(let $20 (DqCnResult (TDqOutput $18 '0) '('"a" '"cc1")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $19 '($20) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType (StructType $11 '('"cc1" $5))) '0 '0)) '('('"type" '"query"))))
)
