Implement MEDIAN, as syntactic sugar over percentile_cont(0.5).
There's a rule in the grammar to accept MEDIAN(x), and turn it into "median(0.5) WITHING GROUP (ORDER BY x)". The median function is identical to percent_cont(), the pg_proc entry borrows percent_cont's implementation. But it's a separate function so that we can distinguish which syntax the user used, for deparsing. In ruleutils.c, check if the special median functions were used, and deparse back the "median(0.5) WITHIN GROUP (ORDER BY x)" into "MEDIAN(x)"
Showing
想要评论请 注册 或 登录