Adds fake CDB_KMeans function

This commit is contained in:
Raul Ochoa 2016-06-29 16:07:01 +02:00
parent cb53d140e3
commit 5f3fb6e5f7

View File

@ -633,3 +633,18 @@ GRANT SELECT ON TABLE analysis_rent_listings TO :PUBLICUSER;
--
GRANT SELECT, UPDATE, INSERT, DELETE ON cdb_analysis_catalog TO :TESTUSER;
create schema cdb_crankshaft;
GRANT USAGE ON SCHEMA cdb_crankshaft TO :TESTUSER;
CREATE TYPE kmeans_type as (cartodb_id numeric, cluster_no numeric);
CREATE OR REPLACE FUNCTION cdb_crankshaft.CDB_KMeans(query text, no_clusters integer,no_init integer default 20)
RETURNS setof kmeans_type as $$
DECLARE r kmeans_type;
BEGIN
FOR r IN EXECUTE format('select cartodb_id, ceil(random() * 10) AS cluster_no from (%s) _cdb_query', query) loop
RETURN NEXT r;
END LOOP;
RETURN;
END;
$$ LANGUAGE plpgsql;
GRANT ALL ON FUNCTION cdb_crankshaft.CDB_KMeans(text, integer, integer) TO :TESTUSER;