Skip to content

Commit

Permalink
Beautifying the queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio committed Oct 2, 2017
1 parent 2d2d381 commit 5a260f4
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions catalog/templates/column.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
SELECT ROW_NUMBER() OVER () AS cartodb_id,
data->0->>'geomref' as geomref,
(data->0->>'value')::Geometry as the_geom,
ST_Transform((data->0->>'value')::Geometry, 3857) as the_geom_webmercator
ST_Transform((data->0->>'value')::Geometry, 3857) AS the_geom_webmercator
FROM OBS_GetData((SELECT ids FROM ids), (SELECT meta FROM meta))

{% else %}
Expand All @@ -82,7 +82,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT cartodb_id as id, the_geom FROM <table_to_update>
SELECT cartodb_id AS id, the_geom FROM <table_to_update>
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
Expand All @@ -103,7 +103,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT 1 as id,
SELECT 1 AS id,
ST_Buffer(ST_SetSRID(ST_Point({{ col['latlng'][1] }}, {{ col['latlng'][0] }}), 4326), 0.01) the_geom
),
meta AS (
Expand All @@ -113,7 +113,7 @@
"normalization": "denominated"}]'
, 1, 1) meta
FROM data)
SELECT id, (data->0->>'value')::{{ col.type }} as {{col.suggested_name}}_rate_{{col.timespan}}
SELECT id, (data->0->>'value')::{{ col.type }} AS {{col.suggested_name}}_rate_{{col.timespan}}
FROM OBS_GetData(
(SELECT ARRAY_AGG((the_geom, id)::geomval) FROM data),
(SELECT meta FROM meta))
Expand All @@ -127,7 +127,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT cartodb_id as id, the_geom FROM <table_to_update>
SELECT cartodb_id AS id, the_geom FROM <table_to_update>
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
Expand All @@ -147,7 +147,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT 1 as id,
SELECT 1 AS id,
ST_Buffer(ST_SetSRID(ST_Point({{ col['latlng'][1] }}, {{ col['latlng'][0] }}), 4326), 0.01) the_geom
),
meta AS (
Expand All @@ -156,7 +156,7 @@
"denom_id": "{{ denom_id }}"}]'
, 1, 1) meta
FROM data)
SELECT id, (data->0->>'value')::{{ col.type }} as {{col.suggested_name}}_estimate_{{col.timespan}}
SELECT id, (data->0->>'value')::{{ col.type }} AS {{col.suggested_name}}_estimate_{{col.timespan}}
FROM OBS_GetData(
(SELECT ARRAY_AGG((the_geom, id)::geomval) FROM data),
(SELECT meta FROM meta))
Expand All @@ -173,7 +173,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT cartodb_id as id, the_geom FROM <table_to_update>
SELECT cartodb_id AS id, the_geom FROM <table_to_update>
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
Expand All @@ -194,7 +194,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT 1 as id,
SELECT 1 AS id,
ST_SetSRID(ST_Point({{ col['latlng'][1] }}, {{ col['latlng'][0] }}), 4326) the_geom
),
meta AS (
Expand All @@ -204,7 +204,7 @@
"normalization": "denominated"}]'
, 1, 1) meta
FROM data)
SELECT id, (data->0->>'value')::{{ col.type }} as {{col.suggested_name}}_{{col.timespan}}
SELECT id, (data->0->>'value')::{{ col.type }} AS {{col.suggested_name}}_{{col.timespan}}
FROM OBS_GetData(
(SELECT ARRAY_AGG((the_geom, id)::geomval) FROM data),
(SELECT meta FROM meta))
Expand All @@ -222,7 +222,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT cartodb_id as id, the_geom FROM <table_to_update>
SELECT cartodb_id AS id, the_geom FROM <table_to_update>
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
Expand All @@ -242,7 +242,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT 1 as id,
SELECT 1 AS id,
ST_Buffer(ST_SetSRID(ST_Point({{ col['latlng'][1] }}, {{ col['latlng'][0] }}), 4326), 0.01) the_geom
),
meta AS (
Expand All @@ -251,7 +251,7 @@
"normalization": "areaNormalized"}]'
, 1, 1) meta
FROM data)
SELECT id, (data->0->>'value')::{{ col.type }} as {{col.suggested_name}}_per_sq_km_{{col.timespan}}
SELECT id, (data->0->>'value')::{{ col.type }} AS {{col.suggested_name}}_per_sq_km_{{col.timespan}}
FROM OBS_GetData(
(SELECT ARRAY_AGG((the_geom, id)::geomval) FROM data),
(SELECT meta FROM meta))
Expand All @@ -264,7 +264,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT cartodb_id as id, the_geom FROM <table_to_update>
SELECT cartodb_id AS id, the_geom FROM <table_to_update>
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
Expand All @@ -284,7 +284,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT 1 as id,
SELECT 1 AS id,
ST_Buffer(ST_SetSRID(ST_Point({{ col['latlng'][1] }}, {{ col['latlng'][0] }}), 4326), 0.01) the_geom
),
meta AS (
Expand All @@ -293,7 +293,7 @@
"normalization": "predenominated"}]'
, 1, 1) meta
FROM data)
SELECT id, (data->0->>'value')::{{ col.type }} as {{col.suggested_name}}_{{col.timespan}}
SELECT id, (data->0->>'value')::{{ col.type }} AS {{col.suggested_name}}_{{col.timespan}}
FROM OBS_GetData(
(SELECT ARRAY_AGG((the_geom, id)::geomval) FROM data),
(SELECT meta FROM meta))
Expand All @@ -307,7 +307,7 @@
.. code-block:: postgresql

WITH data AS (
SELECT cartodb_id as id, the_geom FROM <table_to_update>
SELECT cartodb_id AS id, the_geom FROM <table_to_update>
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
Expand All @@ -326,15 +326,15 @@
.. code-block:: postgresql

WITH data AS (
SELECT 1 as id,
SELECT 1 AS id,
ST_SetSRID(ST_Point({{ col['latlng'][1] }}, {{ col['latlng'][0] }}), 4326) the_geom
),
meta AS (
SELECT OBS_GetMeta(ST_SetSRID(ST_Extent(the_geom), 4326),
'[{"numer_id": "{{ col.id }}"}]'
, 1, 1) meta
FROM data)
SELECT id, (data->0->>'value')::{{ col.type }} as {{col.suggested_name}}_{{col.timespan}}
SELECT id, (data->0->>'value')::{{ col.type }} AS {{col.suggested_name}}_{{col.timespan}}
FROM OBS_GetData(
(SELECT ARRAY_AGG((the_geom, id)::geomval) FROM data),
(SELECT meta FROM meta))
Expand Down

0 comments on commit 5a260f4

Please sign in to comment.