Commit c2e1422c by Marcus Efraimsson Committed by GitHub

Merge pull request #13921 from svenklemm/postgres-delta

Add delta window function to postgres query builder
parents 74c9defe f608340c
......@@ -184,6 +184,11 @@ export default class PostgresQuery {
switch (windows.type) {
case 'window':
switch (windows.params[0]) {
case 'delta':
curr = query;
prev = 'lag(' + curr + ') OVER (' + over + ')';
query = curr + ' - ' + prev;
break;
case 'increase':
curr = query;
prev = 'lag(' + curr + ') OVER (' + over + ')';
......
......@@ -158,6 +158,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
text: 'Window Functions',
value: 'window',
submenu: [
{ text: 'Delta', value: 'delta' },
{ text: 'Increase', value: 'increase' },
{ text: 'Rate', value: 'rate' },
{ text: 'Sum', value: 'sum' },
......
......@@ -107,7 +107,7 @@ register({
{
name: 'function',
type: 'string',
options: ['increase', 'rate', 'sum'],
options: ['delta', 'increase', 'rate', 'sum'],
},
],
defaultParams: ['increase'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment