{"action":"created","issue":{"url":"https://api.github.com/repos/CartoDB/dataservices-api/issues/210","repository_url":"https://api.github.com/repos/CartoDB/dataservices-api","labels_url":"https://api.github.com/repos/CartoDB/dataservices-api/issues/210/labels{/name}","comments_url":"https://api.github.com/repos/CartoDB/dataservices-api/issues/210/comments","events_url":"https://api.github.com/repos/CartoDB/dataservices-api/issues/210/events","html_url":"https://github.com/CartoDB/dataservices-api/pull/210","id":162943334,"number":210,"title":"Add OBS_AugmentTable and OBS_GetTable","user":{"login":"iriberri","id":1730320,"avatar_url":"https://avatars.githubusercontent.com/u/1730320?v=3","gravatar_id":"","url":"https://api.github.com/users/iriberri","html_url":"https://github.com/iriberri","followers_url":"https://api.github.com/users/iriberri/followers","following_url":"https://api.github.com/users/iriberri/following{/other_user}","gists_url":"https://api.github.com/users/iriberri/gists{/gist_id}","starred_url":"https://api.github.com/users/iriberri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iriberri/subscriptions","organizations_url":"https://api.github.com/users/iriberri/orgs","repos_url":"https://api.github.com/users/iriberri/repos","events_url":"https://api.github.com/users/iriberri/events{/privacy}","received_events_url":"https://api.github.com/users/iriberri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-06-29T14:42:02Z","updated_at":"2016-07-01T08:53:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CartoDB/dataservices-api/pulls/210","html_url":"https://github.com/CartoDB/dataservices-api/pull/210","diff_url":"https://github.com/CartoDB/dataservices-api/pull/210.diff","patch_url":"https://github.com/CartoDB/dataservices-api/pull/210.patch"},"body":"* [ ] Use RETURN QUERY or any other variant instead of storing the result in a variable?\r\n\r\nSome notes/details:\r\n\r\n##### Notes regarding style\r\n* I renamed a lot of variables in the client side since last review, I hope this is more clear now\r\n* Python `.format` lines are extra long because of the dictionary I'm using for variable substitution\r\n* There are several lines to build strings that we need to use them in SQL. Mostly, we need a string with the name of the columns separated by commas, and we need a string with a list of names and types (to retrieve the RECORDs from the remote end)\r\n\r\n##### Notes regarding functionality\r\n* I'm creating temporary tables (for augment function) with a specific prefix and an epoch timestamp. These are **unlogged** and dropped afterwards. Creating temp pg tables would have the inconvenience that we need to know which temporal schema name is the session using. Apparently this is configurable but I never found it.\r\n* In AugmentTable, the function will fail if there's already a column with the name of the measure(s) requested (except for functions that operate over  `the_geom`). We could workaround this by setting different column names (with a timestamp, sufix or whatever) but I don't think this improves anything\r\n* In GetTable, the new table will have **all** columns from the user table except in the case where `the_geom` gets updated or there are columns in the user table with the same name. I will only select columns from the user table which do not collide with the Observatory results (left join). For this I'm making some queries to `pg_attribute`\r\n\r\n##### Usage examples\r\n```sql\r\nselect OBS_AugmentTable('<TABLE_NAME_HERE>', 'GetMeasure', '{\"tag_name\":[\"total_pop\"]}'::json);\r\n````\r\n\r\n```sql\r\nselect _OBS_GetTable('<TABLE_NAME_HERE>','<OUTPUT_TABLE_NAME_HERE>', 'GetMeasure', '{\"tag_name\":[\"total_pop\", \"pop_16_over\"]}'::json);\r\n````\r\n\r\nNote: Current the functions will only work with 'GetMeasure' and one or more tags: `total_pop` and/or `pop_16_over`."},"comment":{"url":"https://api.github.com/repos/CartoDB/dataservices-api/issues/comments/229893622","html_url":"https://github.com/CartoDB/dataservices-api/pull/210#issuecomment-229893622","issue_url":"https://api.github.com/repos/CartoDB/dataservices-api/issues/210","id":229893622,"user":{"login":"iriberri","id":1730320,"avatar_url":"https://avatars.githubusercontent.com/u/1730320?v=3","gravatar_id":"","url":"https://api.github.com/users/iriberri","html_url":"https://github.com/iriberri","followers_url":"https://api.github.com/users/iriberri/followers","following_url":"https://api.github.com/users/iriberri/following{/other_user}","gists_url":"https://api.github.com/users/iriberri/gists{/gist_id}","starred_url":"https://api.github.com/users/iriberri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iriberri/subscriptions","organizations_url":"https://api.github.com/users/iriberri/orgs","repos_url":"https://api.github.com/users/iriberri/repos","events_url":"https://api.github.com/users/iriberri/events{/privacy}","received_events_url":"https://api.github.com/users/iriberri/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T08:53:45Z","updated_at":"2016-07-01T08:53:45Z","body":"Retest this, please"}}
{"actor":{"display_login":"iriberri"}}