Fully qualify function names

This commit is contained in:
Rafa de la Torre 2016-04-19 14:59:33 +02:00
parent 67ae37fb67
commit b1b69113a2
3 changed files with 30 additions and 30 deletions

View File

@ -123,7 +123,7 @@ CREATE OR REPLACE FUNCTION cdb_observatory._TestArea()
AS $$
BEGIN
-- Buffer NYC point by 500 meters
RETURN ST_Buffer(_TestPoint()::geography, 500)::geometry;
RETURN ST_Buffer(cdb_observatory._TestPoint()::geography, 500)::geometry;
END;
$$ LANGUAGE plpgsql;

View File

@ -22,7 +22,7 @@
-- Creates a table of demographic snapshot
CREATE OR REPLACE FUNCTION OBS_GetDemographicSnapshot(geom geometry, time_span text default '2009 - 2013', geometry_level text default '"us.census.tiger".block_group' )
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry, time_span text default '2009 - 2013', geometry_level text default '"us.census.tiger".block_group' )
RETURNS TABLE(
total_pop NUMERIC,
male_pop NUMERIC,
@ -212,9 +212,9 @@ BEGIN
SELECT
dimension As names,
dimension_value As vals
FROM OBS_GetCensus($1,$2,$3,$4)
FROM cdb_observatory.OBS_GetCensus($1,$2,$3,$4)
)' ||
OBS_BuildSnapshotQuery(target_cols) ||
cdb_observatory.OBS_BuildSnapshotQuery(target_cols) ||
' FROM a';
RETURN QUERY
@ -233,7 +233,7 @@ $$ LANGUAGE plpgsql;
--Returns arrays of values for the given census dimension names for a given
--point or polygon
CREATE OR REPLACE FUNCTION OBS_GetCensus(
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetCensus(
geom geometry,
dimension_names text[],
time_span text DEFAULT '2009 - 2013',
@ -245,17 +245,17 @@ DECLARE
ids text[];
BEGIN
ids := OBS_LookupCensusHuman(dimension_names);
ids := cdb_observatory.OBS_LookupCensusHuman(dimension_names);
RETURN QUERY
SELECT names, vals FROM OBS_Get(geom, ids, time_span, geometry_level);
SELECT names, vals FROM cdb_observatory.OBS_Get(geom, ids, time_span, geometry_level);
END;
$$ LANGUAGE plpgsql;
-- Base augmentation fucntion.
CREATE OR REPLACE FUNCTION OBS_Get(
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_Get(
geom geometry,
column_ids text[],
time_span text,
@ -268,10 +268,10 @@ DECLARE
geom_table_name text;
names text[];
query text;
data_table_info OBS_ColumnData[];
data_table_info cdb_observatory.OBS_ColumnData[];
BEGIN
geom_table_name := OBS_GeomTable(geom, geometry_level);
geom_table_name := cdb_observatory.OBS_GeomTable(geom, geometry_level);
IF geom_table_name IS NULL
THEN
@ -279,7 +279,7 @@ BEGIN
RETURN QUERY SELECT '{}'::text[], '{}'::NUMERIC[];
END IF;
data_table_info := OBS_GetColumnData(geometry_level,
data_table_info := cdb_observatory.OBS_GetColumnData(geometry_level,
column_ids,
time_span);
@ -288,13 +288,13 @@ BEGIN
IF ST_GeometryType(geom) = 'ST_Point'
THEN
results := OBS_GetPoints(geom,
results := cdb_observatory.OBS_GetPoints(geom,
geom_table_name,
data_table_info);
ELSIF ST_GeometryType(geom) IN ('ST_Polygon', 'ST_MultiPolygon')
THEN
results := OBS_GetPolygons(geom,
results := cdb_observatory.OBS_GetPolygons(geom,
geom_table_name,
data_table_info);
END IF;
@ -311,10 +311,10 @@ $$ LANGUAGE plpgsql;
-- If the variable of interest is just a rate return it as such,
-- otherwise normalize it to the census block area and return that
CREATE OR REPLACE FUNCTION OBS_GetPoints(
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetPoints(
geom geometry,
geom_table_name text,
data_table_info OBS_ColumnData[]
data_table_info cdb_observatory.OBS_ColumnData[]
)
RETURNS NUMERIC[]
AS $$
@ -392,10 +392,10 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION OBS_GetPolygons(
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetPolygons(
geom geometry,
geom_table_name text,
data_table_info OBS_ColumnData[]
data_table_info cdb_observatory.OBS_ColumnData[]
)
RETURNS NUMERIC[]
AS $$
@ -562,7 +562,7 @@ target_cols := Array[
EXECUTE
$query$
SELECT (categories)[1]
FROM OBS_GetCategories(
FROM cdb_observatory.OBS_GetCategories(
$1,
Array['"us.census.spielman_singleton_segments".X10'],
$2)
@ -587,7 +587,7 @@ target_cols := Array[
FROM a)
SELECT $4, percentiles.*
FROM percentiles
$query$, OBS_BuildSnapshotQuery(target_cols));
$query$, cdb_observatory.OBS_BuildSnapshotQuery(target_cols));
RETURN QUERY
EXECUTE
@ -599,7 +599,7 @@ $$ LANGUAGE plpgsql;
--Get categorical variables from point
CREATE OR REPLACE FUNCTION OBS_GetCategories(
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetCategories(
geom geometry,
dimension_names text[],
geometry_level text DEFAULT '"us.census.tiger".block_group',
@ -612,10 +612,10 @@ DECLARE
names text[];
results text[];
query text;
data_table_info OBS_ColumnData[];
data_table_info cdb_observatory.OBS_ColumnData[];
BEGIN
geom_table_name := OBS_GeomTable(geom, geometry_level);
geom_table_name := cdb_observatory.OBS_GeomTable(geom, geometry_level);
IF geom_table_name IS NULL
THEN
@ -623,7 +623,7 @@ BEGIN
RETURN QUERY SELECT '{}'::text[], '{}'::text[];
END IF;
data_table_info := OBS_GetColumnData(geometry_level,
data_table_info := cdb_observatory.OBS_GetColumnData(geometry_level,
dimension_names,
time_span);

View File

@ -84,23 +84,23 @@ SELECT
-- {12996.8172420752}
SELECT
OBS_GetPolygons(
_TestArea(),
cdb_observatory.OBS_GetPolygons(
cdb_observatory._TestArea(),
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::OBS_ColumnData]
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
);
-- see what happens around null island
SELECT
OBS_GetPolygons(
cdb_observatory.OBS_GetPolygons(
ST_Buffer(CDB_LatLng(0, 0)::geography, 500)::geometry,
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::OBS_ColumnData]
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
);
SELECT * FROM
cdb_observatory.OBS_GetSegmentSnapshot(
_TestPoint(),
cdb_observatory._TestPoint(),
'"us.census.tiger".census_tract'
);
@ -113,7 +113,7 @@ SELECT * FROM
SELECT * FROM
cdb_observatory.OBS_GetCategories(
_TestPoint(),
cdb_observatory._TestPoint(),
Array['"us.census.spielman_singleton_segments".X10'],
'"us.census.tiger".census_tract'
);