Add overview tests
This commit is contained in:
parent
06ca4f74ee
commit
8d1bbc63fa
19
test/CDB_OverviewsTest.sql
Normal file
19
test/CDB_OverviewsTest.sql
Normal file
@ -0,0 +1,19 @@
|
||||
SET client_min_messages TO error;
|
||||
\set VERBOSITY default
|
||||
|
||||
\i test/overviews/fixtures.sql
|
||||
|
||||
SELECT _CDB_Aggregable_Attributes_Expression('base_bare_t'::regclass);
|
||||
SELECT _CDB_Aggregated_Attributes_Expression('base_bare_t'::regclass);
|
||||
SELECT _CDB_Aggregated_Attributes_Expression('base_bare_t'::regclass, 'tab');
|
||||
|
||||
SELECT CDB_CreateOverviews('base_bare_t'::regclass);
|
||||
|
||||
SELECT _CDB_Aggregable_Attributes_Expression('base_t'::regclass);
|
||||
SELECT _CDB_Aggregated_Attributes_Expression('base_t'::regclass);
|
||||
SELECT _CDB_Aggregated_Attributes_Expression('base_t'::regclass, 'tab');
|
||||
|
||||
SELECT CDB_CreateOverviews('base_t'::regclass);
|
||||
|
||||
DROP TABLE base_bare_t;
|
||||
DROP TABLE base_t;
|
15
test/CDB_OverviewsTest_expect
Normal file
15
test/CDB_OverviewsTest_expect
Normal file
@ -0,0 +1,15 @@
|
||||
SET
|
||||
CREATE TABLE
|
||||
INSERT 0 1114
|
||||
CREATE TABLE
|
||||
INSERT 0 1114
|
||||
|
||||
|
||||
|
||||
{base_bare_t_ov5,base_bare_t_ov3,base_bare_t_ov1}
|
||||
number,int_number,name,start
|
||||
AVG(number)::double precision AS number,AVG(int_number)::integer AS int_number,''::text AS name,NULL::date AS start
|
||||
AVG(tab.number)::double precision AS number,AVG(tab.int_number)::integer AS int_number,''::text AS name,NULL::date AS start
|
||||
{base_t_ov5,base_t_ov3,base_t_ov1}
|
||||
DROP TABLE
|
||||
DROP TABLE
|
2234
test/overviews/fixtures.sql
Normal file
2234
test/overviews/fixtures.sql
Normal file
File diff suppressed because it is too large
Load Diff
43
test/overviews/gen_points.rb
Normal file
43
test/overviews/gen_points.rb
Normal file
@ -0,0 +1,43 @@
|
||||
# Ruby script to generate test/overviews/fixtures.sql for testing overviews
|
||||
# Generated tables:
|
||||
# * base_bare_t -- points without attributes (only PK, geometries)
|
||||
|
||||
NUM_CLUSTERS = 128
|
||||
MAX_PER_CLUSTER = 16
|
||||
CLUSTER_RADIUS = 1E-3
|
||||
MIN_X = -10.0
|
||||
MAX_X = 10.0
|
||||
MIN_Y = 30.0
|
||||
MAX_Y = 40.0
|
||||
ATTRIBUTES = "number double precision, int_number integer, name text, start date"
|
||||
|
||||
id = 0
|
||||
POINTS = (0...NUM_CLUSTERS).map{
|
||||
x = MIN_X + rand()*(MAX_X - MIN_X)
|
||||
y = MIN_Y + rand()*(MAX_Y - MIN_Y)
|
||||
(0..rand(MAX_PER_CLUSTER)).map{
|
||||
id += 1
|
||||
{
|
||||
id: id,
|
||||
x: (x + rand()*CLUSTER_RADIUS).round(6),
|
||||
y: (y + rand()*CLUSTER_RADIUS).round(6)
|
||||
}
|
||||
}
|
||||
}.flatten
|
||||
|
||||
values = POINTS.map{ |point|
|
||||
"#{point[:id]}, 'SRID=4326;POINT(#{point[:x]} #{point[:y]})'::geometry, ST_Transform('SRID=4326;POINT(#{point[:x]} #{point[:y]})'::geometry, 3857)"
|
||||
}
|
||||
|
||||
File.open('fixtures.sql', 'w') do |sql|
|
||||
|
||||
sql.puts "-- bare table with no attribute columns"
|
||||
sql.puts "CREATE TABLE base_bare_t (cartodb_id integer, the_geom geometry, the_geom_webmercator geometry);"
|
||||
sql.puts "INSERT INTO base_bare_t VALUES"
|
||||
sql.puts values.map{|v| "(#{v})"}.join(",\n") + ";"
|
||||
|
||||
sql.puts "-- table with attributes"
|
||||
sql.puts "CREATE TABLE base_t (cartodb_id integer, the_geom geometry, the_geom_webmercator geometry, #{ATTRIBUTES});"
|
||||
sql.puts "INSERT INTO base_t VALUES"
|
||||
sql.puts values.map{|v| "(#{v})"}.join(",\n") + ";"
|
||||
end
|
Loading…
Reference in New Issue
Block a user