Merge pull request #237 from CartoDB/analysis-catalog

Adds table for storing camshaft analysis nodes
This commit is contained in:
Raul Ochoa 2016-04-19 15:32:46 +02:00
commit 808fc9fc25
4 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,24 @@
-- Table to register analysis nodes from https://github.com/cartodb/camshaft
CREATE TABLE IF NOT EXISTS
cartodb.cdb_analysis_catalog (
-- md5 hex hash
node_id char(40) CONSTRAINT cdb_analysis_catalog_pkey PRIMARY KEY,
-- being json allows to do queries like analysis_def->>'type' = 'buffer'
analysis_def json NOT NULL,
-- can reference other nodes in this very same table, allowing recursive queries
input_nodes char(40) ARRAY NOT NULL DEFAULT '{}',
status TEXT NOT NULL DEFAULT 'pending',
CONSTRAINT valid_status CHECK (
status IN ( 'pending', 'waiting', 'running', 'canceled', 'failed', 'ready' )
),
created_at timestamp with time zone NOT NULL DEFAULT now(),
-- should be updated when some operation was performed in the node
-- and anything associated to it might have changed
updated_at timestamp with time zone DEFAULT NULL,
-- should register last time the node was used
used_at timestamp with time zone NOT NULL DEFAULT now(),
-- should register the number of times the node was used
hits NUMERIC DEFAULT 0,
-- should register what was the last node using current node
last_used_from char(40)
);

View File

@ -0,0 +1 @@
../scripts-available/CDB_AnalysisCatalog.sql

View File

@ -3,4 +3,5 @@ SET SCHEMA 'cartodb';
\i scripts-available/CDB_TableMetadata.sql \i scripts-available/CDB_TableMetadata.sql
\i scripts-available/CDB_ColumnNames.sql \i scripts-available/CDB_ColumnNames.sql
\i scripts-available/CDB_ColumnType.sql \i scripts-available/CDB_ColumnType.sql
\i scripts-available/CDB_AnalysisCatalog.sql
SET SCHEMA 'public'; SET SCHEMA 'public';

View File

@ -563,6 +563,13 @@ test_extension|public|"local-table-with-dashes"'
DATABASE=fdw_target tear_down_database DATABASE=fdw_target tear_down_database
} }
function test_cdb_catalog_basic_node() {
DEF="'{\"type\":\"buffer\",\"source\":\"b2db66bc7ac02e135fd20bbfef0fdd81b2d15fad\",\"radio\":10000}'"
sql postgres "INSERT INTO cartodb.cdb_analysis_catalog (node_id, analysis_def) VALUES ('1bbc4c41ea7c9d3a7dc1509727f698b7', ${DEF}::json)"
sql postgres "SELECT status from cartodb.cdb_analysis_catalog where node_id = '1bbc4c41ea7c9d3a7dc1509727f698b7'" should 'pending'
sql postgres "DELETE FROM cartodb.cdb_analysis_catalog"
}
#################################################### TESTS END HERE #################################################### #################################################### TESTS END HERE ####################################################
run_tests $@ run_tests $@