addding expected results

This commit is contained in:
Andy Eschbacher 2016-04-13 15:54:30 -04:00
parent 6ee0b99bd4
commit 9a398530b3
2 changed files with 3063 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,79 @@
SELECT set_config(
'search_path',
current_setting('search_path') || ',cdb_observatory',
false
) WHERE current_setting('search_path') !~ '(^|,)cdb_observatory(,|$)';
set_config
------------------------------------------
"$user", public, cartodb,cdb_observatory
(1 row)
-- OBS_GeomTable
-- get table with known geometry_id
-- should give back a table like obs_{hex hash}
SELECT
cdb_observatory.OBS_GeomTable(
CDB_LatLng(40.7128,-74.0059),
'"us.census.tiger".census_tract'
);
obs_geomtable
----------------------------------------------
obs_a92e1111ad3177676471d66bb8036e6d057f271b
(1 row)
-- get null for unknown geometry_id
-- should give back null
SELECT
cdb_observatory.OBS_GeomTable(
CDB_LatLng(40.7128,-74.0059),
'"us.census.tiger".nonexistant_id'
);
obs_geomtable
---------------
(1 row)
-- OBS_GetColumnData
-- should give back:
-- colname | tablename | aggregate
-- -----------|-----------------|-----------
-- geoid | obs_{hex table} | null
-- total_pop | obs_{hex table} | sum
SELECT
(unnest(cdb_observatory.OBS_GetColumnData(
'"us.census.tiger".census_tract',
Array['"us.census.tiger".census_tract_geoid', '"us.census.acs".B01001001'],
'2009 - 2013'
))).*
ORDER BY 1 ASC;
colname | tablename | aggregate
-----------+----------------------------------------------+-----------
geoid | obs_11ee8b82c877c073438bc935a91d3dfccef875d1 |
geoid | obs_65f29658e096ca1485bf683f65fdbc9f05ec3c5d |
geoid | obs_ab038198aaab3f3cb055758638ee4de28ad70146 |
geoid | obs_d34555209878e8c4b37cf0b2b3d072ff129ec470 |
total_pop | obs_ab038198aaab3f3cb055758638ee4de28ad70146 | sum
(5 rows)
-- OBS_LookupCensusHuman
-- should give back: {"\"us.census.acs\".B19083001"}
SELECT
cdb_observatory.OBS_LookupCensusHuman(
Array['gini_index']
);
obs_lookupcensushuman
---------------------------------
{"\"us.census.acs\".B19083001"}
(1 row)
-- OBS_BuildSnapshotQuery
-- Should give back: SELECT vals[1] As total_pop, vals[2] As male_pop, vals[3] As female_pop, vals[4] As median_age
SELECT
cdb_observatory.OBS_BuildSnapshotQuery(
Array['total_pop','male_pop','female_pop','median_age']
);
obs_buildsnapshotquery
-------------------------------------------------------------------------------------------------
SELECT vals[1] As total_pop, vals[2] As male_pop, vals[3] As female_pop, vals[4] As median_age
(1 row)