(
(let $1 (DataType 'Interval))
(let $2 (OptionalType $1))
(let $3 (OptionalType (DataType 'Uint32)))
(let $4 '('"age" $1))
(let $5 '('"age_opt" $2))
(let $6 '('"name" (DataType 'String)))
(let $7 '('"region" $3))
(let $8 (StructType $4 $5 $6 $7))
(let $9 '('('"_logical_id" '10853) '('"_id" '"939ccfa7-9e1e0597-daa2f932-c9a51fb2") '('"_wide_channels" $8)))
(let $10 (DqPhyStage '() (lambda '() (block '(
  (let $17 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $18 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $17)))
  (let $19 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $20 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $21 (YtTable '"Input" $18 $19 $20 '() (Void) (Void) '"/Root/plato"))
  (let $22 '('"key" '"subkey" '"value"))
  (let $23 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $21 $22 (Void) (Void))) '()))))
  (let $24 (lambda '($25 $26 $27) (block '(
    (let $28 (Coalesce (SafeCast $25 $2) (SafeCast (Int32 '0) $1)))
    (return $28 (Just $28) $27 (SafeCast $26 $3))
  ))))
  (return (FromFlow (WideMap (DqReadWideWrap $23 '()) $24)))
))) $9))
(let $11 (DqCnHashShuffle (TDqOutput $10 '0) '('"3") '0 '"HashV2"))
(let $12 (DqPhyStage '($11) (lambda '($29) (block '(
  (let $30 (NarrowSqueezeToDict (ToFlow $29) (lambda '($32 $33 $34 $35) $35) (lambda '($36 $37 $38 $39) (AsStruct '('"age" $36) '('"age_opt" $37) '('"name" $38) '('"region" $39))) '('Auto 'Many)))
  (let $31 (Chopper (OrderedFlatMap $30 (lambda '($40) (OrderedFlatMap (DictPayloads $40) (lambda '($41) (Sort $41 (Bool 'false) (lambda '($42) (Member $42 '"name"))))))) (lambda '($43) (Member $43 '"region")) (lambda '($44 $45) (AggrNotEquals $44 (Member $45 '"region"))) (lambda '($46 $47) (block '(
    (let $48 (DataType 'Double))
    (let $49 '($48))
    (let $50 (ResourceType '"Stat.TDigestResource"))
    (let $51 '($50))
    (let $52 (CallableType '() $49 $51 $49))
    (let $53 '('('"strict")))
    (let $54 (Udf '"Stat.TDigest_GetPercentile" (Void) (VoidType) '"" $52 (VoidType) '"" $53))
    (let $55 (DependsOn (Uint32 '1)))
    (let $56 (Double '"0.8"))
    (let $57 (DataType 'Int64))
    (let $58 (DependsOn (Uint32 '2)))
    (let $59 (Nothing $2))
    (let $60 (lambda '($81) (Just (NamedApply (Udf '"Stat.TDigest_Create" (Void) (VoidType) '"" (CallableType '('2) $51 $49 '((OptionalType $48)) '((OptionalType $48))) (VoidType) '"" '()) '((SafeCast $81 $48)) (AsStruct) $58))))
    (let $61 (Nothing (OptionalType $50)))
    (let $62 (Chain1Map $47 (lambda '($67) (block '(
      (let $68 '((OptionalType $48)))
      (let $69 (CallableType '('2) $51 $49 $68 $68))
      (let $70 (Udf '"Stat.TDigest_Create" (Void) (VoidType) '"" $69 (VoidType) '"" '()))
      (let $71 (Member $67 '"age"))
      (let $72 (NamedApply $70 '((SafeCast $71 $48)) (AsStruct) $55))
      (let $73 (Apply $54 $72 $56))
      (let $74 (Member $67 '"age_opt"))
      (let $75 (IfPresent $74 (lambda '($78) (block '(
        (let $79 (NamedApply $70 '((SafeCast $78 $48)) (AsStruct) $58))
        (let $80 (Apply $54 $79 $56))
        (return (Just (Unwrap (SafeCast (ToIntegral $80 $57) $2))))
      ))) $59))
      (let $76 (AsStruct '('Percentile0 (Unwrap (SafeCast (ToIntegral $73 $57) $2))) '('Percentile1 $75) '('"age" $71) '('"age_opt" $74) '('"name" (Member $67 '"name")) '('"region" (Member $67 '"region"))))
      (let $77 (IfPresent $74 $60 $61))
      (return '($76 (AsStruct '('Percentile0 $72) '('Percentile1 $77))))
    ))) (lambda '($82 $83) (block '(
      (let $84 (CallableType '() $51 $51 $49))
      (let $85 (Udf '"Stat.TDigest_AddValue" (Void) (VoidType) '"" $84 (VoidType) '"" $53))
      (let $86 (Nth $83 '1))
      (let $87 (Member $82 '"age"))
      (let $88 (NamedApply $85 '((Member $86 'Percentile0) (SafeCast $87 $48)) (AsStruct) $55))
      (let $89 (Apply $54 $88 $56))
      (let $90 (Member $82 '"age_opt"))
      (let $91 (IfPresent $90 $60 $61))
      (let $92 (IfPresent (Member $86 'Percentile1) (lambda '($95) (IfPresent $90 (lambda '($96) (Just (NamedApply $85 '($95 (SafeCast $96 $48)) (AsStruct) $58))) (Just $95))) $91))
      (let $93 (IfPresent $92 (lambda '($97) (block '(
        (let $98 (Apply $54 $97 $56))
        (return (Just (Unwrap (SafeCast (ToIntegral $98 $57) $2))))
      ))) $59))
      (let $94 (AsStruct '('Percentile0 (Unwrap (SafeCast (ToIntegral $89 $57) $2))) '('Percentile1 $93) '('"age" $87) '('"age_opt" $90) '('"name" (Member $82 '"name")) '('"region" (Member $82 '"region"))))
      (return '($94 (AsStruct '('Percentile0 $88) '('Percentile1 $92))))
    )))))
    (let $63 (StructType '('Percentile0 $1) '('Percentile1 $2) $4 $5 $6 $7))
    (let $64 (ListType $63))
    (let $65 (VariantType (StructType '('group $64) '('singleRow $63))))
    (let $66 (Condense1 $62 (lambda '($99) (block '(
      (let $100 (Nth $99 '0))
      (let $101 (Variant $100 'singleRow $65))
      (return '((Member $100 '"name") $101))
    ))) (lambda '($102 $103) (AggrNotEquals (Member (Nth $102 '0) '"name") (Nth $103 '0))) (lambda '($104 $105) (block '(
      (let $106 (Nth $104 '0))
      (let $107 (Visit (Nth $105 '1) 'group (lambda '($108) (Variant (Insert $108 $106) 'group $65)) 'singleRow (lambda '($109) (Variant (AsList $109 $106) 'group $65))))
      (return '((Nth $105 '0) $107))
    )))))
    (return (OrderedFlatMap $66 (lambda '($110) (block '(
      (let $111 (Visit (Nth $110 '1) 'group (lambda '($112) (IfPresent (Last $112) (lambda '($113) (OrderedMap (Collect (Map $112 (lambda '($114) (AsStruct '('"age" (Member $114 '"age")) '('"age_opt" (Member $114 '"age_opt")) '('"name" (Member $114 '"name")) '('"region" (Member $114 '"region")))))) (lambda '($115) (AsStruct '('Percentile0 (Member $113 'Percentile0)) '('Percentile1 (Member $113 'Percentile1)) '('"age" (Member $115 '"age")) '('"age_opt" (Member $115 '"age_opt")) '('"name" (Member $115 '"name")) '('"region" (Member $115 '"region")))))) (List $64))) 'singleRow (lambda '($116) (AsList $116))))
      (return (Map $111 (lambda '($117) (AsStruct '('Percentile0 (Member $117 'Percentile0)) '('Percentile1 (Member $117 'Percentile1))))))
    )))))
  )))))
  (return (FromFlow (Map $31 (lambda '($118) (AsStruct '('"age_opt_p80" (Member $118 'Percentile1)) '('"age_p80" (Member $118 'Percentile0)))))))
))) '('('"_logical_id" '11320) '('"_id" '"e1dcc94f-a46c3cf4-11abf7b4-9fda9c71"))))
(let $13 (DqCnUnionAll (TDqOutput $12 '0)))
(let $14 (DqPhyStage '($13) (lambda '($119) $119) '('('"_logical_id" '11494) '('"_id" '"5dd6fb24-5c921192-4f7f1f09-aa520f56"))))
(let $15 '($10 $12 $14))
(let $16 (DqCnResult (TDqOutput $14 '0) '('"age_p80" '"age_opt_p80")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $15 '($16) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType (StructType '('"age_opt_p80" $2) '('"age_p80" $1))) '0 '0)) '('('"type" '"query"))))
)
