-- load the previously generated data
sys = load 'datasets="Testing Notebook" tables="test_data_for_join_01f4f7bfadd9ee5ab2568d73ee7b9dda"' using BeansTable();
-- load the collapse information table
collapse = load 'datasets="core collapse and blue stragglers" tables="collapseMyr_vs_bssdynBssEvol"' using BeansTable();
-- join sys and collapse by sys::moccaid == collapse::dsid
j = join sys by moccaid, collapse by dsid;
-- generate the columns and add a collapse column (1 - collapsed, 0 - not collapsed)
j = foreach j generate sys::tbid 	as tbid,
						sys::dsid 	as dsid,
                        sys::moccaid	as moccaid,
                        sys::tphys	as tphys,
                        collapse::collapseMyr 	as collapseMyr,
                        collapse::confidence	as confidence,
                        (sys::tphys < collapse::collapseMyr ? 0 : 1) as collapsed:int
                        ;
-- store the joined table
store j into 'name="test_01f4f7bfadd9ee5ab2568d73ee7b9dda_with_collapse"' using BeansTable();