You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2015/10/31 00:16:37 UTC

[29/51] [partial] incubator-asterixdb git commit: SQL++ parser: 1. refactored asterix-aql to become asterix-lang-common and asterix-lang-aql, where the former is the common part for different languages; 2. added asterix-lang-sqlpp on top of asterix-lang-

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp
new file mode 100644
index 0000000..0458c9f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_01.sqlpp
@@ -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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData1(MyRecordNested) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData1 (nested.point) type rtree;
+
+write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.point)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp
new file mode 100644
index 0000000..7893c9b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_02.sqlpp
@@ -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    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData2' has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData1(MyRecordNested) primary key nested.id;
+
+create  table MyData2(MyRecord) primary key id;
+
+create  index rtree_index  on MyData2 (point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.point)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp
new file mode 100644
index 0000000..35c6196
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_03.sqlpp
@@ -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    : Self-joins a dataset on the intersection of its point attribute.
+ *                  The dataset has an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecord as
+ closed {
+  id : int32,
+  point : point,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordNested as
+ closed {
+  nested : MyRecord
+}
+
+create  table MyData(MyRecordNested) primary key nested.id;
+
+create  index rtree_index  on MyData (nested.point) type rtree;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_03.adm"
+select element {'a':a,'b':b}
+from  MyData as a,
+      MyData as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp
new file mode 100644
index 0000000..fcd5ac4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_04.sqlpp
@@ -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    : Joins two datasets on the intersection of their point attributes.
+ *                  Both datasets 'MyData' and 'MyData2' have an enforced open RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNestedOpen as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordOpen as
+ closed {
+  nested : MyRecordNestedOpen
+}
+
+create  table MyData1(MyRecordOpen) primary key nested.id;
+
+create  table MyData2(MyRecordOpen) primary key nested.id;
+
+create  index rtree_index  on MyData1 (nested.point:point) type rtree enforced;
+
+create  index rtree_index2  on MyData2 (nested.point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp
new file mode 100644
index 0000000..39a7c66
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested-open-index/rtree-index-join/spatial-intersect-point_05.sqlpp
@@ -0,0 +1,59 @@
+/*
+ * 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    : Joins two datasets on the intersection of their point attributes.
+ *                  Only dataset 'MyData1' has an enforced open RTree index, hence we
+ *                  *do not* expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.MyRecordNestedOpen as
+{
+  id : int32,
+  kwds : string,
+  line1 : line,
+  line2 : line,
+  poly1 : polygon,
+  poly2 : polygon,
+  rec : rectangle
+}
+
+create type test.MyRecordOpen as
+ closed {
+  nested : MyRecordNestedOpen
+}
+
+create  table MyData1(MyRecordOpen) primary key nested.id;
+
+create  table MyData2(MyRecordOpen) primary key nested.id;
+
+create  index rtree_index  on MyData1 (nested.point:point) type rtree enforced;
+
+write output to nc1:"rttest/rtree-index-join_spatial-intersect-point_02.adm"
+select element {'a':a,'b':b}
+from  MyData1 as a,
+      MyData2 as b
+where test."spatial-intersect"(a.nested.point,b.nested.point)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp
new file mode 100644
index 0000000..1abe40e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj2.sqlpp
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+write output to nc1:"/tmp/nested_loj.adm"
+select element {'cust':c,'orders':orders}
+from  Customers as c
+with  orders as (
+      select element {'order':o,'items':items}
+      from  Orders as o
+      with  items as (
+            select element l
+            from  LineItems as l
+            where (l.l_orderkey = o.o_orderkey)
+        )
+      where (o.o_custkey = c.c_custkey)
+  )
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp
new file mode 100644
index 0000000..93c153d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/nested_loj3.sqlpp
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+drop  database tpch if exists;
+create  database tpch;
+
+use tpch;
+
+
+create type tpch.LineItemType as
+ closed {
+  l_orderkey : int32,
+  l_partkey : int32,
+  l_suppkey : int32,
+  l_linenumber : int32,
+  l_quantity : double,
+  l_extendedprice : double,
+  l_discount : double,
+  l_tax : double,
+  l_returnflag : string,
+  l_linestatus : string,
+  l_shipdate : string,
+  l_commitdate : string,
+  l_receiptdate : string,
+  l_shipinstruct : string,
+  l_shipmode : string,
+  l_comment : string
+}
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : int32,
+  o_custkey : int32,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : int32,
+  o_comment : string
+}
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : int32,
+  c_name : string,
+  c_address : string,
+  c_nationkey : int32,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+}
+
+create type tpch.PartSuppType as
+ closed {
+  ps_partkey : int32,
+  ps_suppkey : int32,
+  ps_availqty : int32,
+  ps_supplycost : double,
+  ps_comment : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table LineItems(LineItemType) primary key l_orderkey,l_linenumber on group1;
+
+create  table Orders(OrderType) primary key o_orderkey on group1;
+
+create  table Customers(CustomerType) primary key c_custkey on group1;
+
+create  table PartSupp(PartSuppType) primary key ps_partkey,ps_suppkey on group1;
+
+write output to nc1:"/tmp/nested_loj.adm"
+select element {'cust':c,'orders':orders}
+from  Customers as c
+with  orders as (
+      select element {'order':o,'items':items}
+      from  Orders as o
+      with  items as (
+            select element {'item':l,'part_supplier':partsupp}
+            from  LineItems as l
+            with  partsupp as (
+                  select element ps
+                  from  PartSupp as ps
+                  where ((ps.ps_partkey = l.l_partkey) and (ps.ps_suppkey = l.l_suppkey))
+              )
+            where (l.l_orderkey = o.o_orderkey)
+        )
+      where (o.o_custkey = c.c_custkey)
+  )
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp
new file mode 100644
index 0000000..3e78b25
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/disjunction-to-join.sqlpp
@@ -0,0 +1,44 @@
+/*
+ * 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    : Disjunctive predicate should be transformed into collection scan.
+ *                  Secondary index should be used to probe the values retrieved from collection.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TestType as
+{
+  id : string,
+  "no-idx" : string
+}
+
+create  table TestSet(TestType) primary key id;
+
+create  index TestSetIndex  on TestSet (idx:string) type btree enforced;
+
+select element x
+from  TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two'))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
new file mode 100644
index 0000000..f3b1479
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_1.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
new file mode 100644
index 0000000..60e721e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_01_2.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountAIx  on TweetMessages (countA:int32) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_01.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where (t1.countA /*+ indexnl */  = t2.countB)
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
new file mode 100644
index 0000000..148a4f4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_1.sqlpp
@@ -0,0 +1,67 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string,
+  countA : int32
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
new file mode 100644
index 0000000..ab89fab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/leftouterjoin-probe-pidx-with-join-btree-sidx_02_2.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary btree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.TwitterUserType as
+ closed {
+  "screen-name" : string,
+  lang : string,
+  "friends-count" : int32,
+  "statuses-count" : int32,
+  name : string,
+  "followers-count" : int32
+}
+
+create type test.TweetMessageType as
+{
+  tweetid : int64,
+  user : TwitterUserType,
+  "sender-location" : point,
+  "send-time" : datetime,
+  "referred-topics" : {{string}},
+  "message-text" : string
+}
+
+create  table TweetMessages(TweetMessageType) primary key tweetid;
+
+create  index msgCountAIx  on TweetMessages (countA:int32) type btree enforced;
+
+create  index msgCountBIx  on TweetMessages (countB:int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_leftouterjoin-probe-pidx-with-join-btree-sidx_02.adm"
+select element {'tweetid1':t1.tweetid,'count1':t1.countA,'t2info':(
+        select element {'tweetid2':t2.tweetid,'count2':t2.countB}
+        from  TweetMessages as t2
+        where ((t1.countA /*+ indexnl */  = t2.countB) and (t1.tweetid != t2.tweetid))
+        order by t2.tweetid
+    )}
+from  TweetMessages as t1
+where (t1.tweetid < test.int64('10'))
+order by t1.tweetid
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp
new file mode 100644
index 0000000..5533e0a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_01.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp
new file mode 100644
index 0000000..0381eb5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_02.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp
new file mode 100644
index 0000000..ea10df7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-join_03.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
new file mode 100644
index 0000000..06c22a3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_01.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_01.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
new file mode 100644
index 0000000..7e113f4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_02.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_02.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
new file mode 100644
index 0000000..cc1809f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_03.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_03.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  > emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
new file mode 100644
index 0000000..8513c6b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_04.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_04.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  < emp2.fname) and (emp1.lname /*+ indexnl */  = emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
new file mode 100644
index 0000000..c3aaad7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_05.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_05.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  > emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
new file mode 100644
index 0000000..0c6b8a3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-composite-key-prefix-join_06.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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  : Notice the query hint to use an indexed nested-loops join plan in both predicates.
+ *              : We expect a plan to have a self-join, which probes dataset Names’s with a prefix of its secondary index.
+ * Expected Res : Success
+ * Date         : 11th November 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.Name as
+{
+  id : int32
+}
+
+create  table Names(Name) primary key id;
+
+create  index Name_idx  on Names (fname:string,lname:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_secondary-composite-key-prefix-prefix-join_06.adm"
+select element {'emp1':emp1,'emp2':emp2}
+from  Names as emp1,
+      Names as emp2
+where ((emp1.fname /*+ indexnl */  = emp2.fname) and (emp1.lname /*+ indexnl */  < emp2.lname))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp
new file mode 100644
index 0000000..97117f6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multiindex.sqlpp
@@ -0,0 +1,74 @@
+/*
+ * 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    : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
+ *                  We first expect FacebookUsers' primary index to be used
+ *                  to satisfy the range condition on it's primary key.
+ *                  FacebookMessages has a secondary btree open index on author-id-copy, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.EmploymentType as
+ closed {
+  "organization-name" : string,
+  "start-date" : date,
+  "end-date" : date?
+}
+
+create type test.FacebookUserType as
+ closed {
+  id : int32,
+  "id-copy" : int32,
+  alias : string,
+  name : string,
+  "user-since" : datetime,
+  "user-since-copy" : datetime,
+  "friend-ids" : {{int32}},
+  employment : [EmploymentType]
+}
+
+create type test.FacebookMessageType as
+{
+  "message-id" : int32,
+  "message-id-copy" : int32,
+  "author-id" : int32,
+  "in-response-to" : int32?,
+  "sender-location" : point?,
+  message : string
+}
+
+create  table FacebookUsers(FacebookUserType) primary key id;
+
+create  table FacebookMessages(FacebookMessageType) primary key "message-id";
+
+create  index fbmIdxAutId  if not exists  on FacebookMessages ("author-id-copy":int32) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm"
+select element {'fbu-ID':user.id,'fbm-auth-ID':message."author-id",'uname':user.name,'message':message.message}
+from  FacebookUsers as user,
+      FacebookMessages as message
+where ((user.id /*+ indexnl */  = message."author-id-copy") and (user.id >= 11000) and (user.id <= 12000))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp
new file mode 100644
index 0000000..a24c904
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join-multipred.sqlpp
@@ -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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ *                  We expect the additional predicates to be put into a select above the
+ *                  primary index search.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multipred.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where ((a.title /*+ indexnl */  = b.title) and (a.authors < b.authors) and (a.misc > b.misc))
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp
new file mode 100644
index 0000000..370dfb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_01.sqlpp
@@ -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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+ closed {
+  id : int32,
+  csxid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_01.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp
new file mode 100644
index 0000000..091c7ee
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_02.sqlpp
@@ -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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  CSX has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+ closed {
+  id : int32,
+  dblpid : string,
+  title : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on CSX (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp
new file mode 100644
index 0000000..dd0e8a2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_03.sqlpp
@@ -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    : Equi self-joins a dataset, DBLP, based on its title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_03.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      DBLP as b
+where (a.title /*+ indexnl */  = b.title)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp
new file mode 100644
index 0000000..25ad745
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_04.sqlpp
@@ -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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  Both DBLP and CSX have secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index_DBLP  on DBLP (title:string) type btree enforced;
+
+create  index title_index  on CSX (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp
new file mode 100644
index 0000000..d4e7952
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index-join/secondary-equi-join_05.sqlpp
@@ -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    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we *do not* expect the join to be transformed into an indexed nested-loop join,
+ *                  because CSX does not declare an enforced open index on field title.
+ * Success        : Yes
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+create type test.DBLPType as
+{
+  id : int32,
+  dblpid : string,
+  authors : string,
+  misc : string
+}
+
+create type test.CSXType as
+{
+  id : int32,
+  csxid : string,
+  authors : string,
+  misc : string
+}
+
+create  table DBLP(DBLPType) primary key id;
+
+create  table CSX(CSXType) primary key id;
+
+create  index title_index  on DBLP (title:string) type btree enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm"
+select element {'arec':a,'brec':b}
+from  DBLP as a,
+      CSX as b
+where (a.title /*+ indexnl */  = b.title)
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp
new file mode 100644
index 0000000..7db87d7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-33.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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 NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname > 'Roger')
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp
new file mode 100644
index 0000000..9241ab4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-34.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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 NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-32.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname >= 'Susan')
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp
new file mode 100644
index 0000000..d957ed4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-35.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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 (usage) test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-33.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname < 'Isa')
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp
new file mode 100644
index 0000000..62f8eed
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-36.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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 NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-34.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname <= 'Vanpatten')
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp
new file mode 100644
index 0000000..12ab41f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-37.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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 NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-35.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname != 'Max')
+;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/391f09e5/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp
new file mode 100644
index 0000000..4b04e48
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries_sqlpp/open-index-enforced/btree-index/btree-secondary-38.sqlpp
@@ -0,0 +1,46 @@
+/*
+ * 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            : 26th Mar 2014
+ */
+
+drop  database test if exists;
+create  database test;
+
+use test;
+
+
+write output to nc1:"rttest/btree-index_btree-secondary-36.adm"
+create type test.TestType as
+{
+  id : int32
+}
+
+create  table testdst(TestType) primary key id;
+
+create  index sec_Idx  on testdst (fname:string,lname:string) type btree enforced;
+
+select element emp
+from  testdst as emp
+where (emp.fname = 'Julio')
+;