vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse test if exists; |
| 2 | |
| 3 | create dataverse test; |
| 4 | use dataverse test; |
| 5 | |
| 6 | create type LineItemType as closed { |
| 7 | l_orderkey: int32, |
| 8 | l_partkey: int32, |
| 9 | l_suppkey: int32, |
| 10 | l_linenumber: int32, |
| 11 | l_quantity: double, |
| 12 | l_extendedprice: double, |
| 13 | l_discount: double, |
| 14 | l_tax: double, |
| 15 | l_returnflag: string, |
| 16 | l_linestatus: string, |
| 17 | l_shipdate: string, |
| 18 | l_commitdate: string, |
| 19 | l_receiptdate: string, |
| 20 | l_shipinstruct: string, |
| 21 | l_shipmode: string, |
| 22 | l_comment: string |
| 23 | } |
| 24 | |
| 25 | create type LineIDType as closed { |
| 26 | l_orderkey: int32, |
| 27 | l_linenumber: int32, |
| 28 | l_suppkey: int32 |
| 29 | } |
| 30 | |
| 31 | create nodegroup group1 if not exists on nc1, nc2; |
| 32 | |
| 33 | create dataset LineItem(LineItemType) |
| 34 | partitioned by key l_orderkey, l_linenumber on group1; |
| 35 | |
| 36 | create dataset LineID(LineIDType) |
| 37 | partitioned by key l_orderkey, l_linenumber on group1; |
| 38 | |
| 39 | load dataset LineItem |
| 40 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 41 | (("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted; |
| 42 | |
| 43 | load dataset LineID |
| 44 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 45 | (("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted; |
| 46 | |
| 47 | insert into dataset LineID ( |
| 48 | for $l in dataset('LineItem') |
| 49 | where $l.l_orderkey<1000 |
| 50 | return { |
| 51 | "l_orderkey": $l.l_orderkey, |
| 52 | "l_partkey": $l.l_linenumber, |
| 53 | "l_suppkey": $l.l_partkey |
| 54 | } |
| 55 | ); |
| 56 | |
| 57 | insert into dataset LineID ( |
| 58 | for $l in dataset('LineItem') |
| 59 | where $l.l_orderkey>=1000 |
| 60 | die after 1000 |
| 61 | return { |
| 62 | "l_orderkey": $l.l_orderkey, |
| 63 | "l_partkey": $l.l_linenumber, |
| 64 | "l_suppkey": $l.l_partkey |
| 65 | } |
| 66 | ); |
| 67 | |
| 68 | write output to nc1:"rttest/failure_insert.adm"; |
| 69 | for $c in dataset('LineID') |
| 70 | order by $c.l_orderkey, $c.l_linenumber |
| 71 | return $c |
| 72 | |