blob: d4ec17711b899b9f9a52e75e95c8eb0790ca939d [file] [log] [blame]
alexander.behm954083a2012-11-15 04:01:23 +00001/*
2 * Description : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its titles' 3-gram tokens.
3 * DBLP has a 3-gram index on title, 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 * We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
6 * Success : Yes
7 */
8
9drop dataverse test if exists;
10create dataverse test;
11use dataverse test;
ramangrover29a3211202013-05-19 11:56:49 -070012set import-private-functions 'true';
alexander.behm954083a2012-11-15 04:01:23 +000013
14create type DBLPType as closed {
15 id: int32,
16 dblpid: string,
17 title: string,
18 authors: string,
19 misc: string
20}
21
ramangrover29669d8f62013-02-11 06:03:32 +000022create dataset DBLP(DBLPType) primary key id;
alexander.behm954083a2012-11-15 04:01:23 +000023
24create index ngram_index on DBLP(title) type ngram(3);
25
26write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm";
27
28for $a in dataset('DBLP')
29for $b in dataset('DBLP')
30let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false))
31where $jacc >= 0.5f and $a.id < $b.id
ramangrover29a3211202013-05-19 11:56:49 -070032return {"atitle": $a.title, "btitle": $b.title, "jacc": $jacc}