http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-58.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-58.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-58.aql new file mode 100644 index 0000000..28e321f --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-58.aql @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : This test is intended to verify that the primary BTree index is used + * : in the optimized query plan. + * Expected Result : Success + * Date : 13th Aug 2012 + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +write output to asterix_nc1:"rttest/btree-index_btree-primary-56.adm"; + +create type TestTypetmp as open { + id : int32, + fname : string, + lname : string +} + +create type TestType as open { + nested : TestTypetmp +} + +create dataset testdst(TestType) primary key nested.id; + +create index sec_Idx on testdst(nested.fname); + +for $emp in dataset('testdst') +where $emp.nested.fname > "Neil" and $emp.nested.fname < "Roger" +return $emp
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-59.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-59.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-59.aql new file mode 100644 index 0000000..9060d83 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-59.aql @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : This test is intended to verify that the secondary BTree index is used + * : in the optimized query plan. + * Expected Result : Success + * Date : 13th Aug 2012 + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +write output to asterix_nc1:"rttest/btree-index_btree-secondary-57.adm"; + +create type TestTypetmp as open { + id : int32, + fname : string, + lname : string +} + +create type TestType as open { + nested : TestTypetmp +} + +create dataset testdst(TestType) primary key nested.id; + +create index sec_Idx on testdst(nested.fname); + +for $emp in dataset('testdst') +where $emp.nested.fname >= "Max" and $emp.nested.fname <= "Roger" +return $emp http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-60.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-60.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-60.aql new file mode 100644 index 0000000..c1840d3 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-60.aql @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : This test is intended to verify that the secondary BTree index is used + * : in the optimized query plan. + * Expected Result : Success + * Date : 13th Aug 2012 + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +write output to asterix_nc1:"rttest/btree-index_btree-secondary-58.adm"; + +create type TestTypetmp as open { + id : int32, + fname : string, + lname : string +} + +create type TestType as open { + nested : TestTypetmp +} + +create dataset testdst(TestType) primary key nested.id; + +create index sec_Idx on testdst(nested.fname); + +for $emp in dataset('testdst') +where $emp.nested.fname = "Max" +return $emp http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql new file mode 100644 index 0000000..1b17b05 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : BTree Index verification test + * : This test is intended to verify that the secondary BTree index is used + * : in the optimized query plan. + * Expected Result : Success + * Date : 13th Aug 2012 + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +write output to asterix_nc1:"rttest/btree-index_btree-secondary-61.adm"; + +create type TestTypetmp as open { + id : int32, + fname : string, + lname : string +} + +create type TestType as open { + nested : TestTypetmp +} + +create dataset testdst(TestType) primary key nested.id; + +create index sec_Idx on testdst(nested.fname,nested.lname); + +for $emp in dataset('testdst') +where $emp.nested.fname > "Craig" and $emp.nested.lname > "Kevin" and $emp.nested.fname <= "Mary" and $emp.nested.lname < "Tomes" +return $emp http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql new file mode 100644 index 0000000..15c84be --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : BTree Index verification test + * : This test is intended to verify that the secondary BTree index is used + * : in the optimized query plan. + * Expected Result : Success + * Date : 11th Nov 2014 + */ + +// Positive test - prefix search + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +write output to asterix_nc1:"rttest/btree-index_btree-secondary-62.adm"; + +create type TestTypetmp as open { + id : int32, + fname : string, + lname : string +} + +create type TestType as open { + nested : TestTypetmp +} + +create dataset testdst(TestType) primary key nested.id; + +create index sec_Idx on testdst(nested.fname,nested.lname); + +for $emp in dataset('testdst') +where $emp.nested.fname = "Julio" and $emp.nested.lname > "Xu" +return $emp http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql new file mode 100644 index 0000000..2e32bcb --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : BTree Index verification test + * : This test is intended to verify that the secondary BTree index is used + * : in the optimized query plan. + * Expected Result : Success + * Date : 11th Nov 2014 + */ + +// Positive test - prefix search + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +write output to asterix_nc1:"rttest/btree-index_btree-secondary-63.adm"; + +create type TestTypetmp as open { + id : int32, + fname : string, + lname : string +} + +create type TestType as open { + nested : TestTypetmp +} + +create dataset testdst(TestType) primary key nested.id; + +create index sec_Idx on testdst(nested.fname,nested.lname); + +for $emp in dataset('testdst') +where $emp.nested.fname < "Julio" and $emp.nested.lname = "Xu" +return $emp http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql new file mode 100644 index 0000000..f977606 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the contains function. + * The index should *not* be applied (see below). + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-contains-panic.adm"; + +// Cannot optimize this query because the string constant is shorter than the gram length. +for $o in dataset('DBLP') +where contains($o.nested.title, "Mu") +order by $o.nested.id +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql new file mode 100644 index 0000000..63e3dba --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the contains function. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-contains.adm"; + +for $o in dataset('DBLP') +where contains($o.nested.title, "Multimedia") +order by $o.nested.id +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql new file mode 100644 index 0000000..7551a42 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.authors) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm"; + +for $o in dataset('DBLP') +where edit-distance-check($o.nested.authors, "Amihay Motro", 1)[0] +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql new file mode 100644 index 0000000..dc0baa5 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.authors) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm"; + +for $o in dataset('DBLP') +where edit-distance($o.nested.authors, "Amihay Motro") <= 1 +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql new file mode 100644 index 0000000..c466756 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query with ~= using edit-distance on strings. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.authors) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm"; + +set simfunction 'edit-distance'; +set simthreshold '1'; + +for $o in dataset('DBLP') +where $o.nested.authors ~= "Amihay Motro" +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql new file mode 100644 index 0000000..346174c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query with ~= using Jaccard on 3-gram tokens. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; +set import-private-functions 'true'; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm"; + +set simfunction 'jaccard'; +set simthreshold '0.8f'; + +for $o in dataset('DBLP') +where gram-tokens($o.nested.title, 3, false) ~= gram-tokens("Transactions for Cooperative Environments", 3, false) +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.aql new file mode 100644 index 0000000..d587987 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.aql @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; +set import-private-functions 'true'; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm"; + +for $o in dataset('DBLP') +where similarity-jaccard-check(gram-tokens($o.nested.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f)[0] +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql new file mode 100644 index 0000000..be61a9d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard function on 3-gram tokens. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; +set import-private-functions 'true'; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-basic_ngram-jaccard.adm"; + +for $o in dataset('DBLP') +where similarity-jaccard(gram-tokens($o.nested.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false)) >= 0.5f +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql new file mode 100644 index 0000000..03072ea --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists. + * The index should *not* be applied (see below). + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + + + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-edit-distance-check-panic.adm"; + +// Index should not be applied because all list elements can be modified by 3 edit operations. +for $c in dataset('Customers') +where edit-distance-check($c.nested.interests, ["computers", "wine", "walking"], 3)[0] +order by $c.nested.cid +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql new file mode 100644 index 0000000..45e12bf --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-edit-distance-check.adm"; + +for $c in dataset('Customers') +where edit-distance-check($c.nested.interests, ["computers", "wine", "walking"], 1)[0] +order by $c.nested.cid +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql new file mode 100644 index 0000000..3998789 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists. + * The index should *not* be applied (see below). + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + + + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-edit-distance-panic.adm"; + +// Index should not be applied because all list elements can be modified by 3 edit operations. +for $c in dataset('Customers') +where edit-distance($c.nested.interests, ["computers", "wine", "walking"]) <= 3 +order by $c.nested.cid +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql new file mode 100644 index 0000000..c5c67a0 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + + + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-edit-distance.adm"; + +for $c in dataset('Customers') +where edit-distance($c.nested.interests, ["computers", "wine", "walking"]) <= 1 +order by $c.nested.cid +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql new file mode 100644 index 0000000..f802444 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query with ~= using edit-distance on lists. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-fuzzyeq-edit-distance.adm"; + +set simfunction 'edit-distance'; +set simthreshold '1'; + +for $c in dataset('Customers') +where $c.nested.interests ~= ["computers", "wine", "walking"] +order by $c.nested.cid +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql new file mode 100644 index 0000000..6ffff30 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on lists. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-fuzzyeq-jaccard.adm"; + +set simfunction 'jaccard'; +set simthreshold '0.8f'; + +for $c in dataset('Customers') +where $c.nested.interests ~= ["databases", "computers", "wine"] +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql new file mode 100644 index 0000000..c618992 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-jaccard-check.adm"; + +for $c in dataset('Customers') +where similarity-jaccard-check($c.nested.interests, ["databases", "computers", "wine"], 0.7f)[0] +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql new file mode 100644 index 0000000..47e900e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on lists. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: [string], + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_olist-jaccard.adm"; + +for $c in dataset('Customers') +where similarity-jaccard($c.nested.interests, ["databases", "computers", "wine"]) >= 0.7f +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql new file mode 100644 index 0000000..a3237a6 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on sets. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: {{string}}, + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_ulist-fuzzyeq-jaccard.adm"; + +set simfunction 'jaccard'; +set simthreshold '0.8f'; + +for $c in dataset('Customers') +where $c.nested.interests ~= {{"computers", "wine", "databases"}} +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql new file mode 100644 index 0000000..9f5cce6 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on sets. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: {{string}}, + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_ulist-jaccard.adm"; + +for $c in dataset('Customers') +where similarity-jaccard-check($c.nested.interests, {{"computers", "wine", "databases"}}, 0.7f)[0] +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql new file mode 100644 index 0000000..7ebe334 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on sets. + * The index should be applied. + * 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 CustomerTypetmp as closed { + cid: int32, + name: string, + age: int32?, + address: AddressType?, + interests: {{string}}, + children: [ { name: string, age: int32? } ] +} + +create type CustomerType as closed { + nested : CustomerTypetmp +} + +create dataset Customers(CustomerType) primary key nested.cid; + +create dataset Customers2(CustomerType) primary key nested.cid; + +create index interests_index on Customers(nested.interests) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_ulist-jaccard.adm"; + +for $c in dataset('Customers') +where similarity-jaccard($c.nested.interests, {{"computers", "databases", "wine"}}) >= 0.7f +return $c http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql new file mode 100644 index 0000000..20bb147 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the contains function. + * The index should *not* be applied (see below). + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index keyword_index on DBLP(nested.title) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_word-contains.adm"; + +// Contains cannot be answered with a word inverted index. +for $o in dataset('DBLP') +where contains($o.nested.title, "Multimedia") +order by $o.nested.id +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql new file mode 100644 index 0000000..f77591c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on word tokens. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index keyword_index on DBLP(nested.title) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm"; + +set simfunction 'jaccard'; +set simthreshold '0.5f'; + +for $o in dataset('DBLP') +where word-tokens($o.nested.title) ~= word-tokens("Transactions for Cooperative Environments") +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql new file mode 100644 index 0000000..5df3ee3 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index keyword_index on DBLP(nested.title) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_word-jaccard-check.adm"; + +for $o in dataset('DBLP') +where similarity-jaccard-check(word-tokens($o.nested.title), word-tokens("Transactions for Cooperative Environments"), 0.5f)[0] +return $o + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql new file mode 100644 index 0000000..5aa8f6e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on word tokens. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index keyword_index on DBLP(nested.title) type keyword; + +write output to asterix_nc1:"rttest/inverted-index-basic_word-jaccard.adm"; + +for $o in dataset('DBLP') +where similarity-jaccard(word-tokens($o.nested.title), word-tokens("Transactions for Cooperative Environments")) >= 0.5f +return $o + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql new file mode 100644 index 0000000..6fbccc9 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using + * two edit-distance-check function of which only the first can be optimized with an index. + * Tests that the optimizer rule correctly drills through the let clauses. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.authors) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"; + +// Only the first edit-distance-check can be optimized with an index. +for $o in dataset('DBLP') +let $eda := edit-distance-check($o.nested.authors, "Amihay Motro", 3) +let $edb := edit-distance-check($o.nested.authors, "Amihay Motro", 5) +where $eda[0] and $edb[0] +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql new file mode 100644 index 0000000..bb2d7a0 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using + * two edit-distance-check function of which only the second can be optimized with an index. + * Tests that the optimizer rule correctly drills through the let clauses. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.authors) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm"; + +// Only the second edit-distance-check can be optimized with an index. +for $o in dataset('DBLP') +let $edb := edit-distance-check($o.nested.authors, "Amihay Motro", 5) +let $eda := edit-distance-check($o.nested.authors, "Amihay Motro", 3) +where $edb[0] and $eda[0] +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let.aql new file mode 100644 index 0000000..a507b05 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let.aql @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings. + * Tests that the optimizer rule correctly drills through the let clauses. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.authors) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let.adm"; + +for $o in dataset('DBLP') +let $ed := edit-distance-check($o.nested.authors, "Amihay Motro", 1) +where $ed[0] +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.aql new file mode 100644 index 0000000..4dac57c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-substring.aql @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on the substring of the field. + * Tests that the optimizer rule correctly drills through the substring function. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; + +create type DBLPNestedType as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested: DBLPNestedType +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm"; + +for $paper in dataset('DBLP') +where edit-distance-check(substring($paper.nested.title, 0, 8), "datbase", 1)[0] +return { + "id" : $paper.nested.id, + "title" : $paper.nested.title +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-let.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-let.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-let.aql new file mode 100644 index 0000000..4067927 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-let.aql @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens. + * Tests that the optimizer rule correctly drills through the let clauses. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; +set import-private-functions 'true'; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-complex_ngram-jaccard-check-let.adm"; + +for $o in dataset('DBLP') +let $jacc := similarity-jaccard-check(gram-tokens($o.nested.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f) +where $jacc[0] +return $o http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.aql ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.aql new file mode 100644 index 0000000..30f3ca4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-jaccard-check-multi-let.aql @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Description : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens. + * Tests that the optimizer rule correctly drills through the let clauses. + * The index should be applied. + * Success : Yes + */ + +drop dataverse test if exists; +create dataverse test; +use dataverse test; +set import-private-functions 'true'; + +create type DBLPTypetmp as closed { + id: int32, + dblpid: string, + title: string, + authors: string, + misc: string +} + +create type DBLPType as closed { + nested : DBLPTypetmp +} + +create dataset DBLP(DBLPType) primary key nested.id; + +create index ngram_index on DBLP(nested.title) type ngram(3); + +write output to asterix_nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm"; + +// This test is complex because we have three assigns to drill into. +for $paper in dataset('DBLP') +let $paper_tokens := gram-tokens($paper.nested.title, 3, false) +let $query_tokens := gram-tokens("Transactions for Cooperative Environments", 3, false) +let $jacc := similarity-jaccard-check($paper_tokens, $query_tokens, 0.5f) +where $jacc[0] +return {"Paper": $paper_tokens, "Query": $query_tokens }