From 16d08ef52bfbac1f3e23a68ecd462f6f5916b834 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Tue, 12 Apr 2016 11:10:55 +0200 Subject: [PATCH] Include and aggregate _vovw_count column to count aggregated features --- scripts-available/CDB_Overviews.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts-available/CDB_Overviews.sql b/scripts-available/CDB_Overviews.sql index b80be3d..f00d1b0 100644 --- a/scripts-available/CDB_Overviews.sql +++ b/scripts-available/CDB_Overviews.sql @@ -510,7 +510,11 @@ BEGIN CASE column_type WHEN 'double precision', 'real', 'integer', 'bigint' THEN - RETURN Format('AVG(%s)::' || column_type, qualified_column); + IF column_name = '_vovw_count' THEN + RETURN 'SUM(_vovw_count)'; + ELSE + RETURN Format('AVG(%s)::' || column_type, qualified_column); + END IF; WHEN 'text' THEN -- TODO: we could define a new aggregate function that returns distinct -- separated values with a limit, adding ellipsis if more values existed @@ -648,6 +652,10 @@ AS $$ SELECT * FROM cols ) AS s INTO columns; + IF NOT columns LIKE '%_vovw_count%' THEN + columns := columns || ', n AS _vovw_count'; + END IF; + EXECUTE Format('DROP TABLE IF EXISTS %I.%I CASCADE;', schema_name, overview_rel); -- Now we cluster the data using a grid of size grid_m