asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject [19/58] [abbrv] [partial] incubator-asterixdb git commit: Added support of typed indexes over open fields & indexes over nested fields
Date Fri, 24 Apr 2015 18:42:45 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.aql
new file mode 100644
index 0000000..24ea718
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance-inline/ngram-edit-distance-inline.4.query.aql
@@ -0,0 +1,15 @@
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+for $a in dataset('Customers')
+for $b in dataset('Customers2')
+let $ed := edit-distance($a.nested.name, $b.nested.name)
+where $ed <= 4 and $a.nested.cid < $b.nested.cid
+order by $ed, $a.nested.cid, $b.nested.cid
+return { "arec": $a.nested, "brec": $b.nested, "ed": $ed }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.aql
new file mode 100644
index 0000000..fb2f2cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.1.ddl.aql
@@ -0,0 +1,35 @@
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as open {
+  number: int64,
+  street: string,
+  city: string
+}
+
+create type CustomerNestedType as closed {
+  cid: int64,
+  name: string,
+  age: int64?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int64? } ]
+}
+
+create type CustomerType as closed {
+  nested: CustomerNestedType
+}
+
+create dataset Customerstmp(CustomerNestedType) primary key cid;
+create dataset Customers2tmp(CustomerNestedType) primary key cid;
+
+create dataset Customers(CustomerType) primary key nested.cid;
+create dataset Customers2(CustomerType) primary key nested.cid;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.aql
new file mode 100644
index 0000000..8c3d677
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+load dataset Customerstmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+load dataset Customers2tmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm"));
+
+insert into dataset Customers
+(
+	for $c in dataset('Customerstmp')
+	return {
+		"nested" : $c
+	}	
+);
+
+insert into dataset Customers2
+(
+	for $c in dataset('Customers2tmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.aql
new file mode 100644
index 0000000..f19953a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.3.ddl.aql
@@ -0,0 +1,10 @@
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+create index ngram_index on Customers(nested.name) type ngram(3);
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.aql
new file mode 100644
index 0000000..3f28374
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-edit-distance/ngram-edit-distance.4.query.aql
@@ -0,0 +1,13 @@
+/*
+ * Description    : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names.
+ *                  Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+for $a in dataset('Customers')
+for $b in dataset('Customers2')
+where edit-distance($a.nested.name, $b.nested.name) <= 4 and $a.nested.cid < $b.nested.cid
+order by $a.nested.cid, $b.nested.cid
+return { "arec": $a.nested, "brec": $b.nested }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.aql
new file mode 100644
index 0000000..68c7df2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.1.ddl.aql
@@ -0,0 +1,41 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPNestedType as closed {
+  id: int64,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested: DBLPNestedType
+}
+
+create type CSXNestedType as closed {
+  id: int64,
+  csxid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as closed {
+  nested: CSXNestedType
+}
+
+create dataset DBLPtmp(DBLPNestedType) primary key id;
+create dataset CSXtmp(CSXNestedType) primary key id;
+
+create dataset DBLP(DBLPType) primary key nested.id;
+create dataset CSX(CSXType) primary key nested.id;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.aql
new file mode 100644
index 0000000..7531754
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+load dataset DBLPtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000")) pre-sorted;
+
+load dataset CSXtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000"));
+
+
+insert into dataset DBLP(
+	for $x in dataset DBLPtmp
+	return {
+		"nested": $x
+	}
+);
+
+insert into dataset CSX(
+	for $x in dataset CSXtmp
+	return {
+		"nested": $x
+	}
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.aql
new file mode 100644
index 0000000..5ac0e7c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.3.ddl.aql
@@ -0,0 +1,11 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
new file mode 100644
index 0000000..46e6524
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard-inline/ngram-jaccard-inline.4.query.aql
@@ -0,0 +1,16 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+set import-private-functions 'true';
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+let $jacc := similarity-jaccard(gram-tokens($a.nested.title, 3, false), gram-tokens($b.nested.title, 3, false))
+where $jacc >= 0.5f and $a.nested.id < $b.nested.id
+order by $jacc, $a.nested.id, $b.nested.id
+return { "arec": $a.nested, "brec": $b.nested, "jacc": $jacc }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.aql
new file mode 100644
index 0000000..5eaa418
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.1.ddl.aql
@@ -0,0 +1,40 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPNestedType as closed {
+  id: int64,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested: DBLPNestedType
+}
+
+create type CSXNestedType as closed {
+  id: int64,
+  csxid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as closed {
+  nested: CSXNestedType
+}
+
+create dataset DBLPtmp(DBLPNestedType) primary key id;
+create dataset CSXtmp(CSXNestedType) primary key id;
+
+create dataset DBLP(DBLPType) primary key nested.id;
+create dataset CSX(CSXType) primary key nested.id;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.aql
new file mode 100644
index 0000000..e8a0f24
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.2.update.aql
@@ -0,0 +1,30 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+load dataset DBLPtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000")) pre-sorted;
+
+load dataset CSXtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000"));
+
+
+insert into dataset DBLP(
+	for $x in dataset DBLPtmp
+	return {
+		"nested": $x
+	}
+);
+
+insert into dataset CSX(
+	for $x in dataset CSXtmp
+	return {
+		"nested": $x
+	}
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.aql
new file mode 100644
index 0000000..ac4a54f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.3.ddl.aql
@@ -0,0 +1,10 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.aql
new file mode 100644
index 0000000..f50db99
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/ngram-jaccard/ngram-jaccard.4.query.aql
@@ -0,0 +1,15 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
+ *                  DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+set import-private-functions 'true';
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+where similarity-jaccard(gram-tokens($a.nested.title, 3, false), gram-tokens($b.nested.title, 3, false)) >= 0.5f
+      and $a.nested.id < $b.nested.id
+order by $a.nested.id, $b.nested.id
+return { "arec": $a.nested, "brec": $b.nested }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.aql
new file mode 100644
index 0000000..184e89b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.1.ddl.aql
@@ -0,0 +1,34 @@
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type MyRecordtmp as closed {
+  id: int64,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create type MyRecord as closed {
+nested : MyRecordtmp
+}
+
+create dataset MyData1tmp(MyRecordtmp) primary key id;
+create dataset MyData2tmp(MyRecordtmp) primary key id;
+
+create dataset MyData1(MyRecord) primary key nested.id;
+create dataset MyData2(MyRecord) primary key nested.id;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.aql
new file mode 100644
index 0000000..708ccdf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.2.update.aql
@@ -0,0 +1,32 @@
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+load dataset MyData1tmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+load dataset MyData2tmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+insert into dataset MyData1
+(
+	for $c in dataset('MyData1tmp')
+	return {
+		"nested" : $c
+	}	
+);
+
+insert into dataset MyData2
+(
+	for $c in dataset('MyData2tmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.aql
new file mode 100644
index 0000000..220be98
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.3.ddl.aql
@@ -0,0 +1,11 @@
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+create index rtree_index on MyData1(nested.point) type rtree;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.aql
new file mode 100644
index 0000000..998ca54
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/rtree-spatial-intersect-point/rtree-spatial-intersect-point.4.query.aql
@@ -0,0 +1,14 @@
+/*
+ * Description    : Joins two datasets on the intersection of their point attributes.
+ *                  The dataset 'MyData1' has an RTree index, and we expect the
+ *                  join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+for $a in dataset('MyData1')
+for $b in dataset('MyData2')
+where spatial-intersect($a.nested.point, $b.nested.point) and $a.nested.id != $b.nested.id
+order by $a.nested.id, $b.nested.id
+return {"aid": $a.nested.id, "bid": $b.nested.id, "apt": $a.nested.point, "bp": $b.nested.point}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.aql
new file mode 100644
index 0000000..31fc8ad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.1.ddl.aql
@@ -0,0 +1,41 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPNestedType as closed {
+  id: int64,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested: DBLPNestedType
+}
+
+create type CSXNestedType as closed {
+  id: int64,
+  csxid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as closed {
+  nested: CSXNestedType
+}
+
+create dataset DBLPtmp(DBLPNestedType) primary key id;
+create dataset CSXtmp(CSXNestedType) primary key id;
+
+create dataset DBLP(DBLPType) primary key nested.id;
+create dataset CSX(CSXType) primary key nested.id;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.aql
new file mode 100644
index 0000000..e825ed5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+load dataset DBLPtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000")) pre-sorted;
+
+load dataset CSXtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000"));
+
+
+insert into dataset DBLP(
+	for $x in dataset DBLPtmp
+	return {
+		"nested": $x
+	}
+);
+
+insert into dataset CSX(
+	for $x in dataset CSXtmp
+	return {
+		"nested": $x
+	}
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.aql
new file mode 100644
index 0000000..f258320
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.3.ddl.aql
@@ -0,0 +1,11 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+create index keyword_index on DBLP(nested.title) type keyword;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.aql
new file mode 100644
index 0000000..d34cd17
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard-inline/word-jaccard-inline.4.query.aql
@@ -0,0 +1,15 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ *                  We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+let $jacc := similarity-jaccard(word-tokens($a.nested.title), word-tokens($b.nested.title))
+where $jacc >= 0.5f and $a.nested.id < $b.nested.id
+order by $jacc, $a.nested.id, $b.nested.id
+return { "arec": $a.nested, "brec": $b.nested, "jacc": $jacc }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.aql
new file mode 100644
index 0000000..75fd7e2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.1.ddl.aql
@@ -0,0 +1,40 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPNestedType as closed {
+  id: int64,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested: DBLPNestedType
+}
+
+create type CSXNestedType as closed {
+  id: int64,
+  csxid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as closed {
+  nested: CSXNestedType
+}
+
+create dataset DBLPtmp(DBLPNestedType) primary key id;
+create dataset CSXtmp(CSXNestedType) primary key id;
+
+create dataset DBLP(DBLPType) primary key nested.id;
+create dataset CSX(CSXType) primary key nested.id;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.2.update.aql
new file mode 100644
index 0000000..3d64eab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.2.update.aql
@@ -0,0 +1,30 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+load dataset DBLPtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000")) pre-sorted;
+
+load dataset CSXtmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":"),("quote"="\u0000"));
+
+
+insert into dataset DBLP(
+	for $x in dataset DBLPtmp
+	return {
+		"nested": $x
+	}
+);
+
+insert into dataset CSX(
+	for $x in dataset CSXtmp
+	return {
+		"nested": $x
+	}
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.aql
new file mode 100644
index 0000000..72ba9aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.3.ddl.aql
@@ -0,0 +1,10 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+create index keyword_index on DBLP(nested.title) type keyword;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.4.query.aql
new file mode 100644
index 0000000..96a4396
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-join/word-jaccard/word-jaccard.4.query.aql
@@ -0,0 +1,14 @@
+/*
+ * Description    : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' word tokens.
+ *                  DBLP has a keyword index on title, and we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+use dataverse test;
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+where similarity-jaccard(word-tokens($a.nested.title), word-tokens($b.nested.title)) >= 0.5f
+      and $a.nested.id < $b.nested.id
+order by $a.nested.id, $b.nested.id
+return { "arec": $a.nested, "brec": $b.nested }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.aql
new file mode 100644
index 0000000..cd9c570
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.1.ddl.aql
@@ -0,0 +1,45 @@
+/*
+ * 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 dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int64,
+	statuses-count: int64,
+	name: string,
+	followers-count: int64
+}
+
+create type TweetMessageNestedType as closed {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string,
+	countA: int64,
+	countB: int64
+}
+
+create type TweetMessageType as closed {
+	nested: TweetMessageNestedType
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key nested.tweetid;
+
+create dataset TweetMessagesTmp(TweetMessageNestedType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(nested.sender-location) type rtree;
+create index msgCountAIx on TweetMessages(nested.countA) type btree;
+create index msgCountBIx on TweetMessages(nested.countB) type btree;
+create index msgTextIx on TweetMessages(nested.message-text) type keyword;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.aql
new file mode 100644
index 0000000..3d8ec7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.2.update.aql
@@ -0,0 +1,20 @@
+/*
+ * 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
+ */
+
+use dataverse test;
+
+load dataset TweetMessagesTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into dataset TweetMessages
+(
+	for $c in dataset('TweetMessagesTmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.aql
new file mode 100644
index 0000000..4a5516c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx1/probe-pidx-with-join-btree-sidx1.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * 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
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+where $t1.nested.tweetid < int64("10")
+order by $t1.nested.tweetid
+return {
+"tweetid1": $t1.nested.tweetid,
+"count1":$t1.nested.countA,
+"t2info": for $t2 in dataset('TweetMessages')
+          where $t1.nested.countA /* +indexnl */= $t2.nested.countB
+          order by $t2.nested.tweetid
+          return {"tweetid2": $t2.nested.tweetid,
+                  "count2":$t2.nested.countB}
+};

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.aql
new file mode 100644
index 0000000..cd9c570
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.1.ddl.aql
@@ -0,0 +1,45 @@
+/*
+ * 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 dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int64,
+	statuses-count: int64,
+	name: string,
+	followers-count: int64
+}
+
+create type TweetMessageNestedType as closed {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string,
+	countA: int64,
+	countB: int64
+}
+
+create type TweetMessageType as closed {
+	nested: TweetMessageNestedType
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key nested.tweetid;
+
+create dataset TweetMessagesTmp(TweetMessageNestedType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(nested.sender-location) type rtree;
+create index msgCountAIx on TweetMessages(nested.countA) type btree;
+create index msgCountBIx on TweetMessages(nested.countB) type btree;
+create index msgTextIx on TweetMessages(nested.message-text) type keyword;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.aql
new file mode 100644
index 0000000..3d8ec7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.2.update.aql
@@ -0,0 +1,20 @@
+/*
+ * 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
+ */
+
+use dataverse test;
+
+load dataset TweetMessagesTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into dataset TweetMessages
+(
+	for $c in dataset('TweetMessagesTmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.aql
new file mode 100644
index 0000000..85992bb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-btree-sidx2/probe-pidx-with-join-btree-sidx2.3.query.aql
@@ -0,0 +1,22 @@
+/*
+ * 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
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+where $t1.nested.tweetid < int64("10")
+order by $t1.nested.tweetid
+return {
+"tweetid1": $t1.nested.tweetid,
+"count1":$t1.nested.countA,
+"t2info": for $t2 in dataset('TweetMessages')
+                        where $t1.nested.countA /* +indexnl */= $t2.nested.countB and
+                        $t1.nested.tweetid != $t2.nested.tweetid
+                        order by $t2.nested.tweetid
+                        return {"tweetid2": $t2.nested.tweetid,
+                                       "count2":$t2.nested.countB}
+};

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.aql
new file mode 100644
index 0000000..cc8f754
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.1.ddl.aql
@@ -0,0 +1,47 @@
+/*
+ * 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 dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int64,
+	statuses-count: int64,
+	name: string,
+	followers-count: int64
+}
+
+create type TweetMessageNestedType as closed {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string,
+	countA: int64,
+	countB: int64
+}
+
+create type TweetMessageType as closed {
+	nested: TweetMessageNestedType
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key nested.tweetid;
+
+create dataset TweetMessagesTmp(TweetMessageNestedType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(nested.sender-location) type rtree;
+create index msgCountAIx on TweetMessages(nested.countA) type btree;
+create index msgCountBIx on TweetMessages(nested.countB) type btree;
+create index msgTextIx on TweetMessages(nested.message-text) type keyword;
+create index msgNgramIx on TweetMessages(nested.message-text) type ngram(3);
+create index topicKeywordIx on TweetMessages(nested.referred-topics) type keyword;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.aql
new file mode 100644
index 0000000..3d8ec7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.2.update.aql
@@ -0,0 +1,20 @@
+/*
+ * 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
+ */
+
+use dataverse test;
+
+load dataset TweetMessagesTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into dataset TweetMessages
+(
+	for $c in dataset('TweetMessagesTmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.aql
new file mode 100644
index 0000000..620f2f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx1/probe-pidx-with-join-invidx-sidx1.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+where $t1.nested.tweetid > int64("240")
+order by $t1.nested.tweetid
+return {
+    "tweet": {"id": $t1.nested.tweetid, "topics" : $t1.nested.referred-topics} ,
+    "similar-tweets": for $t2 in dataset('TweetMessages')
+                      let $sim := similarity-jaccard-check($t1.nested.referred-topics, $t2.nested.referred-topics, 0.5f)
+		      where $sim[0] and
+                      $t2.nested.tweetid != $t1.nested.tweetid
+                      order by $t2.nested.tweetid
+                      return {"id": $t2.nested.tweetid, "topics" : $t2.nested.referred-topics}
+};

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.aql
new file mode 100644
index 0000000..7f2a9c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.1.ddl.aql
@@ -0,0 +1,47 @@
+/*
+ * 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 dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int64,
+	statuses-count: int64,
+	name: string,
+	followers-count: int64
+}
+
+create type TweetMessageNestedType as closed {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string,
+	countA: int64,
+	countB: int64
+}
+
+create type TweetMessageType as closed {
+	nested: TweetMessageNestedType
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key nested.tweetid;
+
+create dataset TweetMessagesTmp(TweetMessageNestedType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(nested.sender-location) type rtree;
+create index msgCountAIx on TweetMessages(nested.countA) type btree;
+create index msgCountBIx on TweetMessages(nested.countB) type btree;
+create index msgTextIx on TweetMessages(nested.message-text) type keyword;
+create index msgNgramIx on TweetMessages(nested.message-text) type ngram(3);
+create index topicKeywordIx on TweetMessages(nested.referred-topics) type keyword;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.aql
new file mode 100644
index 0000000..3d8ec7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.2.update.aql
@@ -0,0 +1,20 @@
+/*
+ * 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
+ */
+
+use dataverse test;
+
+load dataset TweetMessagesTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into dataset TweetMessages
+(
+	for $c in dataset('TweetMessagesTmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.aql
new file mode 100644
index 0000000..2211041
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-invidx-sidx2/probe-pidx-with-join-invidx-sidx2.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary keyword inverted index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 16th May 2014
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+where $t1.nested.tweetid > int64("240")
+order by $t1.nested.tweetid
+return {
+    "tweet": {"id": $t1.nested.tweetid, "topics" : $t1.nested.message-text} ,
+    "similar-tweets": for $t2 in dataset('TweetMessages')
+                      let $sim := edit-distance-check($t1.nested.message-text, $t2.nested.message-text, 7)
+		      where $sim[0] and
+                      $t2.nested.tweetid != $t1.nested.tweetid
+                      order by $t2.nested.tweetid
+                      return {"id": $t2.nested.tweetid, "topics" : $t2.nested.message-text}
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.aql
new file mode 100644
index 0000000..07975fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.1.ddl.aql
@@ -0,0 +1,45 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int64,
+	statuses-count: int64,
+	name: string,
+	followers-count: int64
+}
+
+create type TweetMessageNestedType as closed {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string,
+	countA: int64,
+	countB: int64
+}
+
+create type TweetMessageType as closed {
+	nested: TweetMessageNestedType
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key nested.tweetid;
+
+create dataset TweetMessagesTmp(TweetMessageNestedType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(nested.sender-location) type rtree;
+create index msgCountAIx on TweetMessages(nested.countA) type btree;
+create index msgCountBIx on TweetMessages(nested.countB) type btree;
+create index msgTextIx on TweetMessages(nested.message-text) type keyword;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.aql
new file mode 100644
index 0000000..dfa0993
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.2.update.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use dataverse test;
+
+load dataset TweetMessagesTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into dataset TweetMessages
+(
+	for $c in dataset('TweetMessagesTmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.aql
new file mode 100644
index 0000000..5135a7b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx1/probe-pidx-with-join-rtree-sidx1.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+let $n :=  create-circle($t1.nested.sender-location, 0.5)
+where $t1.nested.tweetid < int64("10")
+order by $t1.nested.tweetid
+return {
+"tweetid1": $t1.nested.tweetid,
+"loc1":$t1.nested.sender-location,
+"nearby-message": for $t2 in dataset('TweetMessages')
+                             where spatial-intersect($t2.nested.sender-location, $n)
+                             order by $t2.nested.tweetid
+                             return {"tweetid2":$t2.nested.tweetid, "loc2":$t2.nested.sender-location}
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.aql
new file mode 100644
index 0000000..07975fb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.1.ddl.aql
@@ -0,0 +1,45 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int64,
+	statuses-count: int64,
+	name: string,
+	followers-count: int64
+}
+
+create type TweetMessageNestedType as closed {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string,
+	countA: int64,
+	countB: int64
+}
+
+create type TweetMessageType as closed {
+	nested: TweetMessageNestedType
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key nested.tweetid;
+
+create dataset TweetMessagesTmp(TweetMessageNestedType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(nested.sender-location) type rtree;
+create index msgCountAIx on TweetMessages(nested.countA) type btree;
+create index msgCountBIx on TweetMessages(nested.countB) type btree;
+create index msgTextIx on TweetMessages(nested.message-text) type keyword;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.aql
new file mode 100644
index 0000000..dfa0993
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.2.update.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use dataverse test;
+
+load dataset TweetMessagesTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
+
+insert into dataset TweetMessages
+(
+	for $c in dataset('TweetMessagesTmp')
+	return {
+		"nested" : $c
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.aql
new file mode 100644
index 0000000..0e30905
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-leftouterjoin/probe-pidx-with-join-rtree-sidx2/probe-pidx-with-join-rtree-sidx2.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+let $n :=  create-circle($t1.nested.sender-location, 0.5)
+where $t1.nested.tweetid < int64("10")
+order by $t1.nested.tweetid
+return {
+"tweetid1": $t1.nested.tweetid,
+"loc1":$t1.nested.sender-location,
+"nearby-message": for $t2 in dataset('TweetMessages')
+                             where spatial-intersect($t2.nested.sender-location, $n) and $t1.nested.tweetid != $t2.nested.tweetid
+                             order by $t2.nested.tweetid
+                             return {"tweetid2":$t2.nested.tweetid, "loc2":$t2.nested.sender-location}
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.aql
new file mode 100644
index 0000000..9f960d5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.1.ddl.aql
@@ -0,0 +1,37 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type EmpTmp as closed {
+id:int64,
+fname:string,
+lname:string,
+age:int64,
+dept:string
+}
+
+create type Nested as closed {
+id:int64,
+fname:string,
+lname:string,
+age:int64,
+dept:string
+}
+
+create type Emp as closed {
+nested : Nested
+}
+
+create dataset employeeTmp(EmpTmp) primary key id;
+
+create dataset employee(Emp) primary key nested.id;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.aql
new file mode 100644
index 0000000..f839625
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.2.update.aql
@@ -0,0 +1,29 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use dataverse test;
+
+load dataset employeeTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+
+insert into dataset employee
+(
+	for $c in dataset('employeeTmp')
+	return {
+		"nested" : {
+	  "id": $c.id,
+  	  "fname": $c.fname,
+  	  "lname": $c.lname,
+  	  "age": $c.age,
+  	  "dept": $c.dept }
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.aql
new file mode 100644
index 0000000..3b32227
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.3.ddl.aql
@@ -0,0 +1,3 @@
+use dataverse test;
+
+create index idx_employee_f_l_name on employee(nested.fname,nested.lname);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.aql
new file mode 100644
index 0000000..af13ac6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key-mixed-intervals/btree-index-composite-key-mixed-intervals.4.query.aql
@@ -0,0 +1,16 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname > "Julio" and $l.lname > "Mattocks" and
+ *					 $l.fname <= "Micco" and $l.lname < "Vangieson"
+ * Expected Result : Success
+ * Issue           : Issue 174
+ * Date            : 5th Feb, 2013
+ */
+
+use dataverse test;
+
+for $l in dataset('employee')
+where $l.nested.fname > "Julio" and $l.nested.lname > "Mattocks" and $l.nested.fname <= "Micco" and $l.nested.lname < "Vangieson"
+order by $l.nested.id
+return $l.nested
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.aql
new file mode 100644
index 0000000..0c9a114
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.1.ddl.aql
@@ -0,0 +1,36 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type EmpTmp as closed {
+id:int64,
+fname:string,
+lname:string,
+age:int64,
+dept:string
+}
+
+create type Nested as closed {
+id:int64,
+fname:string,
+lname:string,
+age:int64,
+dept:string
+}
+
+create type Emp as closed {
+nested : Nested
+}
+
+create dataset employeeTmp(EmpTmp) primary key id;
+
+create dataset employee(Emp) primary key nested.id;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.aql
new file mode 100644
index 0000000..cdb8190
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.2.update.aql
@@ -0,0 +1,28 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use dataverse test;
+
+load dataset employeeTmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/names.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+
+insert into dataset employee
+(
+	for $c in dataset('employeeTmp')
+	return {
+		"nested" : {
+	  "id": $c.id,
+  	  "fname": $c.fname,
+  	  "lname": $c.lname,
+  	  "age": $c.age,
+  	  "dept": $c.dept }
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.aql
new file mode 100644
index 0000000..9d7bfe3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.3.ddl.aql
@@ -0,0 +1,12 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use dataverse test;
+
+create index idx_employee_f_l_name on employee(nested.fname,nested.lname);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.aql
new file mode 100644
index 0000000..23d4fc3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-composite-key/btree-index-composite-key.4.query.aql
@@ -0,0 +1,15 @@
+/*
+ * Description     : Test that BTree index is used in query plan
+ *                 : define the BTree index on a composite key (fname,lanme)
+ *                 : predicate => where $l.fname="Julio" and $l.lname="Isa"
+ * Expected Result : Success
+ * Issue           : Issue 162
+ * Date            : 7th August 2012
+ */
+
+use dataverse test;
+
+for $l in dataset('employee')
+where $l.nested.fname = "Julio" and $l.nested.lname = "Isa"
+order by $l.nested.id
+return $l.nested

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.aql
new file mode 100644
index 0000000..2c2ac7d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.1.ddl.aql
@@ -0,0 +1,43 @@
+/*
+ * Description     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+drop dataverse tpch if exists;
+create dataverse tpch;
+use dataverse tpch;
+
+create type OrderTypetmp as open {
+  o_orderkey: int64,
+  o_custkey: int64,
+  o_orderstatus: string,
+  o_totalprice: double,
+  o_orderdate: string,
+  o_orderpriority: string,
+  o_clerk: string,
+  o_shippriority: int64,
+  o_comment: string
+}
+
+create type Nested as open {
+  o_orderkey: int64,
+  o_custkey: int64,
+  o_orderstatus: string,
+  o_totalprice: double,
+  o_orderdate: string,
+  o_orderpriority: string,
+  o_clerk: string,
+  o_shippriority: int64,
+  o_comment: string
+}
+
+create type OrderType as open {
+nested : Nested
+}
+
+create dataset Orders(OrderType) primary key nested.o_orderkey;
+create dataset Orderstmp(OrderTypetmp) primary key o_orderkey;
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.aql
new file mode 100644
index 0000000..267c1c1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * Description     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use dataverse tpch;
+
+load dataset Orderstmp
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+insert into dataset Orders
+(
+	for $c in dataset('Orderstmp')
+	return {
+		"nested" : {
+  "o_orderkey": $c.o_orderkey,
+  "o_custkey": $c.o_custkey,
+  "o_orderstatus": $c.o_orderstatus,
+  "o_totalprice": $c.o_totalprice,
+  "o_orderdate": $c.o_orderdate,
+  "o_orderpriority": $c.o_orderpriority,
+  "o_clerk": $c.o_clerk,
+  "o_shippriority": $c.o_shippriority,
+  "o_comment": $c.o_comment
+}
+	}	
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.aql
new file mode 100644
index 0000000..cfc8369
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.3.ddl.aql
@@ -0,0 +1,6 @@
+
+use dataverse tpch;
+
+// create secondary index on Orders(o_custkey)
+
+create index idx_Orders_Custkey on Orders(nested.o_custkey);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.aql
new file mode 100644
index 0000000..3324b2c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/nested-index/index-selection/btree-index-rewrite-multiple/btree-index-rewrite-multiple.4.query.aql
@@ -0,0 +1,24 @@
+/*
+ * Description     : Test that multiple subtrees in the same query
+ *                   can be rewritten with secondary BTree indexes.
+ *                   Guards against regression to issue 204.
+ * Expected Result : Success
+ * Issue           : Issue 204
+ */
+
+use dataverse tpch;
+
+for $o in dataset('Orders')
+for $o2 in dataset('Orders')
+where $o.nested.o_custkey = 20 and $o2.nested.o_custkey = 10
+and $o.nested.o_orderstatus < $o2.nested.o_orderstatus
+order by $o.nested.o_orderkey, $o2.nested.o_orderkey
+return {
+  "o_orderkey": $o.nested.o_orderkey,
+  "o_custkey": $o.nested.o_custkey,
+  "o_orderstatus": $o.nested.o_orderstatus,
+  "o_orderkey2": $o2.nested.o_orderkey,
+  "o_custkey2": $o2.nested.o_custkey,
+  "o_orderstatus2": $o2.nested.o_orderstatus
+}
+


Mime
View raw message