blob: a602ca1e032dec9ff7187417ed80e66070545161 [file] [log] [blame]
alexander.behmd1e2cb12012-10-25 08:04:25 +00001/*
2 * Description : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
3 * Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
4 * We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
5 * Success : Yes
6 */
7
8drop dataverse test if exists;
9create dataverse test;
10use dataverse test;
11
12create type AddressType as open {
13 number: int32,
14 street: string,
15 city: string
16}
17
18create type CustomerType as open {
19 cid: int32,
20 name: string,
21 age: int32?,
22 address: AddressType?,
23 interests: [string],
24 children: [ { name: string, age: int32? } ]
25}
26
27create dataset Customers(CustomerType) partitioned by key cid;
28
29create dataset Customers2(CustomerType) partitioned by key cid;
30
31load dataset Customers
32using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
33(("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
34
35load dataset Customers2
36using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
37(("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
38
39create index ngram_index on Customers(name) type ngram(3);
40
alexander.behm954083a2012-11-15 04:01:23 +000041write output to nc1:"rttest/inverted-index-join_ngram-edit-distance-inline.adm";
alexander.behmd1e2cb12012-10-25 08:04:25 +000042
43for $a in dataset('Customers')
44for $b in dataset('Customers2')
45let $ed := edit-distance($a.name, $b.name)
46where $ed <= 4 and $a.cid < $b.cid
47order by $ed, $a.cid, $b.cid
alexander.behm954083a2012-11-15 04:01:23 +000048return { "arec": $a, "brec": $b, "ed": $ed }