Skip to content

Window Analytic Functions #210

Answered by EvgSkv
smdesai asked this question in Q&A
Mar 12, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hello @smdesai
as your query is a single aggregation it seems to make sense to have it as a single aggregate predicate like so:

ApproxPercentile(x) = SqlExpr(
    "approx_percentile({v}, {p})", {v: AsReal(x.v), p: x.p});

AsReal(t) = SqlExpr("cast({t} as real)", {t:});

ElementAt(m, k) = 
  SqlExpr("element_at({m}, {k})", {m:, k:});

Test(p50? ApproxPercentile= {v: runtime, p: 0.5},
     p95? ApproxPercentile= {v: runtime, p: 0.95},
     count? += 1) distinct :-
  applogs(dynamicfields:, ts_date:, pod:),
  runtime == ElementAt(dynamicfields, "runTime"),
  !Like(pod, "cs%"),
  rules_served == ElementAt(dynamicfields, "rulesServed"),
  AsReal(rules_served) > 0,
  ts_date >= "20220201",
  ts…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@smdesai
Comment options

@EvgSkv
Comment options

Answer selected by smdesai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants