From 3faabb822cfc0be13f2f0d6fa5ed368761a9297f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ciesi=C3=B3=C5=82ka?= Date: Sat, 30 Dec 2023 21:26:06 +0100 Subject: [PATCH] Added Pig scripts for testing --- pig_scripts/testing/test_basic_functions.pig | 8 ++++++++ pig_scripts/testing/test_generate_for_join.pig | 8 ++++++++ pig_scripts/testing/test_join_collapse.pig | 17 +++++++++++++++++ pig_scripts/testing/test_load_by_name.pig | 4 ++++ 4 files changed, 37 insertions(+) create mode 100644 pig_scripts/testing/test_basic_functions.pig create mode 100644 pig_scripts/testing/test_generate_for_join.pig create mode 100644 pig_scripts/testing/test_join_collapse.pig create mode 100644 pig_scripts/testing/test_load_by_name.pig diff --git a/pig_scripts/testing/test_basic_functions.pig b/pig_scripts/testing/test_basic_functions.pig new file mode 100644 index 0000000..94c6819 --- /dev/null +++ b/pig_scripts/testing/test_basic_functions.pig @@ -0,0 +1,8 @@ +-- load a single system table from a dataset +sys = load 'datasets="mocca 14bd768a5357ab95df307e58a70657ba" tables="system"' using BeansTable(); +-- generate some example columns +sys = foreach sys generate rchut2, smt; +-- basic filtering +sys = filter sys by smt > 0.0; +-- store into a table +store sys into 'name="test_load_filter_store"' using BeansTable(); diff --git a/pig_scripts/testing/test_generate_for_join.pig b/pig_scripts/testing/test_generate_for_join.pig new file mode 100644 index 0000000..1830204 --- /dev/null +++ b/pig_scripts/testing/test_generate_for_join.pig @@ -0,0 +1,8 @@ +-- load system table from a single dataset +sys = load 'datasets="mocca 01f4f7bfadd9ee5ab2568d73ee7b9dda" tables="system"' using BeansTable(); +-- generate only the needed columns for this test +sys = foreach sys generate DSID(tbid) as dsid, + DSPARAMSTRING(DSID(tbid), 'moccaid') as moccaid, + tphys; +-- store the data +store sys into 'name="test_data_for_join_01f4f7bfadd9ee5ab2568d73ee7b9dda"' using BeansTable(); diff --git a/pig_scripts/testing/test_join_collapse.pig b/pig_scripts/testing/test_join_collapse.pig new file mode 100644 index 0000000..3c1fc0a --- /dev/null +++ b/pig_scripts/testing/test_join_collapse.pig @@ -0,0 +1,17 @@ +-- 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(); diff --git a/pig_scripts/testing/test_load_by_name.pig b/pig_scripts/testing/test_load_by_name.pig new file mode 100644 index 0000000..da7cb04 --- /dev/null +++ b/pig_scripts/testing/test_load_by_name.pig @@ -0,0 +1,4 @@ +-- load a table that was previously saved +sys = load 'datasets="Testing Notebook" tables="test_load_filter_store"' using BeansTable(); +-- store the loaded table to check if it lads correctly +store sys into 'name="TEST_LOAD_BY_NAME_FROM_NOTEBOOK"' using BeansTable();