 CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetBoundaryById(
   geometry_id text,            -- ex: '36047'
   boundary_id text,            -- ex: '"us.census.tiger".county'
-  time_span text DEFAULT NULL  --ex: '2009'
+  time_span text DEFAULT NULL  -- ex: '2009'
 )
 RETURNS geometry(geometry, 4326)
 AS $$

  geom_colname text;
BEGIN

SELECT * INTO geoid_colname, target_table, geom_colname
FROM cdb_observatory._OBS_GetGeometryMetadata(boundary_id);

  RAISE NOTICE '%', target_table;


  target_table text;
BEGIN

  IF lower(overlap_type) NOT IN ('contains', 'within', 'intersects')
  THEN
    RAISE EXCEPTION 'Overlap type ''%'' is not an accepted type (choose contains, within, intersects)', overlap_type;
  ELSIF ST_GeometryType(geom) NOT IN ('ST_Polygon', 'ST_MultiPolygon')
  THEN
      RAISE EXCEPTION 'Invalid geometry type (%), expecting ''ST_MultiPolygon'' or ''ST_Polygon''', ST_GeometryType(geom);
  END IF;

  SELECT * INTO geoid_colname, target_table, geom_colname
  FROM cdb_observatory._OBS_GetGeometryMetadata(boundary_id);

  RAISE NOTICE 'geoid_colname: %, target_table: %, geom_colname: %',
               geoid_colname, target_table, geom_colname;

  -- if no tables are found, raise notice and return null
  IF target_table IS NULL
