alexander.behm | 417fb9b | 2012-11-15 19:36:44 +0000 | [diff] [blame] | 1 | /* |
| 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 expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary. |
| 5 | * Success : Yes |
| 6 | */ |
| 7 | |
| 8 | drop dataverse test if exists; |
| 9 | create dataverse test; |
| 10 | use dataverse test; |
| 11 | |
| 12 | create type AddressType as open { |
| 13 | number: int32, |
| 14 | street: string, |
| 15 | city: string |
| 16 | } |
| 17 | |
| 18 | create 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 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 27 | create dataset Customers(CustomerType) primary key cid; |
alexander.behm | 417fb9b | 2012-11-15 19:36:44 +0000 | [diff] [blame] | 28 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 29 | create dataset Customers2(CustomerType) primary key cid; |
alexander.behm | 417fb9b | 2012-11-15 19:36:44 +0000 | [diff] [blame] | 30 | |
| 31 | load dataset Customers |
| 32 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 33 | (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm")); |
| 34 | |
| 35 | load dataset Customers2 |
| 36 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 37 | (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm")); |
| 38 | |
| 39 | create index ngram_index on Customers(name) type ngram(3); |
| 40 | |
| 41 | write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-edit-distance.adm"; |
| 42 | |
| 43 | for $a in dataset('Customers') |
| 44 | for $b in dataset('Customers2') |
| 45 | where edit-distance($a.name, $b.name) <= 4 and $a.cid < $b.cid |
| 46 | order by $a.cid, $b.cid |
| 47 | return { "a": $a.name, "b": $b.name } |