From 9f0b4e0aa779072d64da581976d74b825afc49fe Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Wed, 18 Jul 2018 13:29:47 +0200 Subject: [PATCH] add groupby when adding first aggregate --- public/app/plugins/datasource/postgres/query_ctrl.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/app/plugins/datasource/postgres/query_ctrl.ts b/public/app/plugins/datasource/postgres/query_ctrl.ts index a0523e10c7c..68eac1cf34a 100644 --- a/public/app/plugins/datasource/postgres/query_ctrl.ts +++ b/public/app/plugins/datasource/postgres/query_ctrl.ts @@ -234,6 +234,10 @@ export class PostgresQueryCtrl extends QueryCtrl { this.selectModels.push(parts); break; case 'aggregate': + // add group by if no group by yet + if (this.target.groupBy.length === 0) { + this.addGroupBy('time', '1m'); + } case 'special': let index = _.findIndex(selectParts, (p: any) => p.def.type === item.value); if (index !== -1) {