I need to create a breadcrumb field in a child/father table in greenplum MPP
The original table has 2 fields: father, child I need to extract a view with the breadcrumb
For example having this records
1, 2
1, 3
2, 4
4, 5
I need to extract:
1/2
1/3
1/2/4
1/2/4/5
and so on
Greenplum is an MPP processing engine based on postgresql 8.2. Basically it's a postgres but, giving the version, it does not support the "with recursive" postgresql feature from 8.3.
Furthermore if i try to create a function to do the job i encounter other GP limitations
For example if i create a function like the following
CREATE OR REPLACE FUNCTION getBreadCrumb(decimal) RETURNS text AS 'DECLARE
itemid ALIAS FOR $1;
itemfullname text;
itemrecord RECORD;
BEGIN
SELECT * INTO itemrecord FROM mytable where father=itemid;
itemfullname := coalesce(itemfullname, '''') || itemrecord.father::text;
IF itemrecord.child IS NOT NULL THEN
itemfullname := itemfullname || ''/'' || getBreadCrumb(itemrecord.child)::text ;
RETURN itemfullname;
ELSE
RETURN itemfullname;
END IF;
END' LANGUAGE 'plpgsql'
and then try to select from that i get
ERROR: function cannot execute on segment because it accesses relation "mytable" (functions.c:152)
which to me seems related to the 'shared nothing' architecture of greenplum.
Any other idea to create the breadcrumb giving the environment i have?
thanks in advance