[Swift-commit] r3955 - provenancedb

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Jan 12 10:52:57 CST 2011


Author: lgadelha
Date: 2011-01-12 10:52:57 -0600 (Wed, 12 Jan 2011)
New Revision: 3955

Modified:
   provenancedb/pql_functions.sql
   provenancedb/prov-init.sql
Log:
Added support for lineage queries using SQL recursion.



Modified: provenancedb/pql_functions.sql
===================================================================
--- provenancedb/pql_functions.sql	2011-01-12 16:24:09 UTC (rev 3954)
+++ provenancedb/pql_functions.sql	2011-01-12 16:52:57 UTC (rev 3955)
@@ -149,3 +149,18 @@
 	       ds_usage.param_name='prot' OR ds_usage.param_name='prepTarFile' OR ds_usage.param_name='nSim') AND
 	       annot_wf_txt.name='oops_run_id' AND annot_wf_txt.value=$1;
 $$ LANGUAGE SQL;
+
+-- recursive query to find ancestor entities in a provenance graph
+
+create or replace function ancestors(varchar) returns setof varchar as $$
+       with recursive anc(ancestor,descendant) as
+         (    
+              select parent as ancestor, child as descendant from parent_of where child=$1
+              union all
+              select parent_of.parent as ancestor, anc.descendant as descendant
+              from   anc,parent_of
+              where  anc.ancestor=parent_of.child
+         )
+       select ancestor from anc
+$$ language sql;
+

Modified: provenancedb/prov-init.sql
===================================================================
--- provenancedb/prov-init.sql	2011-01-12 16:24:09 UTC (rev 3954)
+++ provenancedb/prov-init.sql	2011-01-12 16:52:57 UTC (rev 3955)
@@ -198,6 +198,13 @@
      primary key (id, name)
    );
 
+create view parent_of as 
+       select process_id as parent,dataset_id as child from ds_usage where direction='O'
+       union
+       select dataset_id as parent,process_id as child from ds_usage where direction='I'
+       union 
+       select out_id as parent,in_id as child from ds_containment;
+
 -- extrainfo stores lines generated by the SWIFT_EXTRA_INFO feature
 -- extrainfo will be processes into annotation tables
 -- CREATE TABLE extrainfo




More information about the Swift-commit mailing list