blob: 8eb173a8b623f3ef207960444f991a74d214a5f9 [file] [log] [blame]
/*
* Description : Fuzzy joins two datasets, Customers and Customers2, based on the Jaccard similarity of their interest sets.
* Customers has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join.
* We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
* Success : Yes
*/
drop dataverse test if exists;
create dataverse test;
use dataverse test;
create type AddressType as closed {
number: int32,
street: string,
city: string
}
create type CustomerType as closed {
cid: int32,
name: string,
age: int32?,
address: AddressType?,
interests: {{string}},
children: [ { name: string, age: int32? } ]
}
create dataset Customers(CustomerType) partitioned by key cid;
create dataset Customers2(CustomerType) partitioned by key cid;
load dataset Customers
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
(("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
load dataset Customers2
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
(("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm"));
create index interests_index on Customers(interests) type keyword;
write output to nc1:"rttest/index-join_inverted-index-ulist-jaccard-inline.adm";
for $a in dataset('Customers')
for $b in dataset('Customers2')
let $jacc := /*+ indexnl */ similarity-jaccard($a.interests, $b.interests)
where $jacc >= 0.9f and $a.cid < $b.cid and len($a.interests) > 1 and len($b.interests) > 1
order by $jacc, $a.cid, $b.cid
return { "a": $a.interests, "b": $b.interests, "jacc": $jacc }