Fix for issue 813 - enabling prefix btree search with non-matching predicates

Change-Id: I59eb43afa7dbcabd7f43269566d75c9361c55386
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/171
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
index 164e49a..e688a9b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
@@ -1,6 +1,6 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : This test is intended to verify that the primary BTree index is used 
  *                  : in the optimized query plan for predicates.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
index 659d1ff..7453d41 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
@@ -1,12 +1,12 @@
 /*
  *  Description     : BTree Index verification (usage) test
- *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : This test is intended to verify that the primary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// Negative test - prefix search
+// Positive test - prefix search
 
 drop dataverse test if exists;
 create dataverse test;
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
index 3c49200..d98636c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
@@ -1,12 +1,12 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : This test is intended to verify that the primary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// Negative test - prefix search
+// Positive test - prefix search
 
 drop dataverse test if exists;
 create dataverse test;
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
index e93061f..fc4964e 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
@@ -1,6 +1,6 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : This test is intended to verify that the primary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
index db9c994..65b7086 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
@@ -1,6 +1,6 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the primary BTree index is NOT used 
+ *                  : This test is intended to verify that the primary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-31.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-31.aql
new file mode 100644
index 0000000..8cf4641
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-31.aql
@@ -0,0 +1,26 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+// Positive test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm";
+
+create type TestType as open {
+    fname : string,
+    lname : string
+}
+
+create dataset testdst(TestType) primary key fname,lname;
+
+for $emp in dataset('testdst') 
+where $emp.fname = "Julio" and $emp.lname > "Xu"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-32.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-32.aql
new file mode 100644
index 0000000..0a6930b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-32.aql
@@ -0,0 +1,26 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the primary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+// Positive test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-32.adm";
+
+create type TestType as open {
+    fname : string,
+    lname : string
+}
+
+create dataset testdst(TestType) primary key fname,lname;
+
+for $emp in dataset('testdst') 
+where $emp.fname < "Julio" and $emp.lname = "Xu"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql
deleted file mode 100644
index f2a12d6..0000000
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-32.aql
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is used 
- *                  : in the optimized query plan.
- *  Expected Result : Success
- *  Date            : 13th Aug 2012
- */
-
-// This is a Positive test - prefix search, BTree index should be used in the plan.
-
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
-write output to nc1:"rttest/btree-index_btree-secondary-32.adm";
-
-create type TestType as open {
-    id : int32,
-    fname : string,
-    lname : string
-}
-
-create dataset testdst(TestType) primary key id;
-
-create index sec_Idx on testdst(fname,lname);
-
-for $emp in dataset('testdst') 
-where $emp.fname >= "Susan"
-return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql
index f73fe6d..dea4276 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-33.aql
@@ -1,18 +1,18 @@
 /*
- *  Description     : BTree Index verification (usage) test
+ *  Description     : BTree Index verification test
  *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// Positive test - prefix search, BTree index should be used.
+// Please note this is a Positive test and the BTree index should be used in the plan.
 
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-secondary-33.adm";
+write output to nc1:"rttest/btree-index_btree-primary-33.adm";
 
 create type TestType as open {
     id : int32,
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname < "Isa"
+where $emp.fname > "Roger"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql
index c637649..a8a0f40 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-34.aql
@@ -6,7 +6,7 @@
  *  Date            : 13th Aug 2012
  */
 
-// Positive test - prefix search, BTree index should be used in query plan
+// This is a Positive test - prefix search, BTree index should be used in the plan.
 
 drop dataverse test if exists;
 create dataverse test;
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname <= "Vanpatten"
+where $emp.fname >= "Susan"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql
index dfc5017..7d003eb 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-35.aql
@@ -1,12 +1,12 @@
 /*
- *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *  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            : 13th Aug 2012
  */
 
-// Negative test - BTree index should NOT be used in query plan
+// Positive test - prefix search, BTree index should be used.
 
 drop dataverse test if exists;
 create dataverse test;
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname != "Max"
+where $emp.fname < "Isa"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql
index 894ba63..f9c070d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-36.aql
@@ -6,7 +6,7 @@
  *  Date            : 13th Aug 2012
  */
 
-// Positive test - prefix search, BTree index should be used in the query plan.
+// Positive test - prefix search, BTree index should be used in query plan
 
 drop dataverse test if exists;
 create dataverse test;
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname = "Julio"
+where $emp.fname <= "Vanpatten"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql
index 7c155ce..a771083 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-37.aql
@@ -1,12 +1,12 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
+ *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// THE BTREE INDEX IN THIS CASE SHOULD NOT BE PICKED UP!!!!
-// Verify that the optimized query plan does not have the BTree search
+// Negative test - BTree index should NOT be used in query plan
 
 drop dataverse test if exists;
 create dataverse test;
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.lname = "Kim"
+where $emp.fname != "Max"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql
index dc63f05..ba47170 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-38.aql
@@ -1,10 +1,13 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan 
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
+// Positive test - prefix search, BTree index should be used in the query plan.
+
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -22,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname = "Young Seok" and $emp.lname = "Kim"
+where $emp.fname = "Julio"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql
index a9d32c3..a480186 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-39.aql
@@ -1,12 +1,12 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
- *                  : in the optimized query plan.
+ *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// Negative test
+// THE BTREE INDEX IN THIS CASE SHOULD NOT BE PICKED UP!!!!
+// Verify that the optimized query plan does not have the BTree search
 
 drop dataverse test if exists;
 create dataverse test;
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname = "Julio" or $emp.lname = "Malaika"
+where $emp.lname = "Kim"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql
index 25c6dec..7301b1c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-40.aql
@@ -1,7 +1,6 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is used 
- *                  : in the optimized query plan.
+ *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan 
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
@@ -23,5 +22,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Alex" and $emp.lname < "Zach"
+where $emp.fname = "Young Seok" and $emp.lname = "Kim"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql
index bc65009..950f5fd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-41.aql
@@ -6,6 +6,8 @@
  *  Date            : 13th Aug 2012
  */
 
+// Negative test
+
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -23,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Allan" and $emp.lname < "Zubi"
+where $emp.fname = "Julio" or $emp.lname = "Malaika"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql
index 289d1b4..e7a378b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-42.aql
@@ -1,13 +1,11 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// Negative test - prefix search
-
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -25,5 +23,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Allan" and $emp.lname = "Xu"
+where $emp.fname > "Alex" and $emp.lname < "Zach"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql
index 86e5d67..5db96b2 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-43.aql
@@ -1,13 +1,11 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
-// Negative test - prefix search
-
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -25,5 +23,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname = "Julio" and $emp.lname < "Xu"
+where $emp.fname > "Allan" and $emp.lname < "Zubi"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql
index 54e149e..7e8bcc6 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-44.aql
@@ -1,11 +1,13 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
 
+// Positive test - prefix search
+
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -23,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname >= "Michael" and $emp.lname <= "Xu"
+where $emp.fname > "Allan" and $emp.lname = "Xu"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql
index cc33e5a..62c30dc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-45.aql
@@ -6,6 +6,8 @@
  *  Date            : 13th Aug 2012
  */
 
+// Positive test - prefix search
+
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -23,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
+where $emp.fname = "Julio" and $emp.lname < "Xu"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql
index f486e44..48e6112 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-46.aql
@@ -23,5 +23,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
+where $emp.fname >= "Michael" and $emp.lname <= "Xu"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql
index 5d06a51..ed0f145 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-47.aql
@@ -1,6 +1,6 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
@@ -23,5 +23,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname <= "Craig" and $emp.lname > "Kevin"
+where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql
index 2dc1ab4..c1ec5bd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-48.aql
@@ -1,7 +1,7 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is NOT used 
- *                  : in the optimized query plan 
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
@@ -23,5 +23,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname != "Michael" and $emp.lname != "Carey"
+where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql
index 6175ba6..09132fc 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-49.aql
@@ -18,11 +18,10 @@
     lname : string
 }
 
-// create internal dataset
 create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
+where $emp.fname <= "Craig" and $emp.lname > "Kevin"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql
index 04aefc3..89d12cd 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-50.aql
@@ -1,7 +1,7 @@
 /*
  *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is used 
- *                  : in the optimized query plan.
+ *                  : This test is intended to verify that the secondary BTree index is NOT used 
+ *                  : in the optimized query plan 
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
  */
@@ -23,5 +23,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
+where $emp.fname != "Michael" and $emp.lname != "Carey"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql
index 5ae63a9..d702d7d 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-51.aql
@@ -18,10 +18,11 @@
     lname : string
 }
 
+// create internal dataset
 create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
-for $emp in dataset('testdst')
-where $emp.fname >= "Craig" and $emp.lname <= "Kevin" and $emp.fname <= "Mary" and $emp.lname >= "Tomes"
+for $emp in dataset('testdst') 
+where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql
index e720742..cfc97c4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-52.aql
@@ -1,5 +1,6 @@
 /*
- *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
@@ -16,11 +17,11 @@
     fname : string,
     lname : string
 }
- 
+
 create dataset testdst(TestType) primary key id;
 
-create index sec_Idx on testdst(fname);
+create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Max" 
+where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql
index 65a9b6d..d4e8381 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-53.aql
@@ -1,5 +1,6 @@
 /*
- *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
@@ -19,8 +20,8 @@
 
 create dataset testdst(TestType) primary key id;
 
-create index sec_Idx on testdst(fname);
+create index sec_Idx on testdst(fname,lname);
 
-for $emp in dataset('testdst') 
-where $emp.fname >= "Sofia" 
+for $emp in dataset('testdst')
+where $emp.fname >= "Craig" and $emp.lname <= "Kevin" and $emp.fname <= "Mary" and $emp.lname >= "Tomes"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql
index a18975a..f06ba1b 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-54.aql
@@ -16,11 +16,11 @@
     fname : string,
     lname : string
 }
-
+ 
 create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
 for $emp in dataset('testdst') 
-where $emp.fname < "Chen" 
+where $emp.fname > "Max" 
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql
index 94c1463..cb1b8b4 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-55.aql
@@ -22,5 +22,5 @@
 create index sec_Idx on testdst(fname);
 
 for $emp in dataset('testdst') 
-where $emp.fname <= "Julio" 
+where $emp.fname >= "Sofia" 
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql
index 53f8ca4..01b4735 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-56.aql
@@ -1,5 +1,5 @@
 /*
- *  Description     : This test is intended to verify that the primary BTree index is used 
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
@@ -9,7 +9,7 @@
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-primary-56.adm";
+write output to nc1:"rttest/btree-index_btree-secondary-56.adm";
 
 create type TestType as open {
     id : int32,
@@ -22,5 +22,5 @@
 create index sec_Idx on testdst(fname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Neil" and $emp.fname < "Roger" 
+where $emp.fname < "Chen" 
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql
index 43cf54d..5d21013 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-57.aql
@@ -22,5 +22,5 @@
 create index sec_Idx on testdst(fname);
 
 for $emp in dataset('testdst') 
-where $emp.fname >= "Max" and $emp.fname <= "Roger" 
+where $emp.fname <= "Julio" 
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql
index aa18136..5113aca 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-58.aql
@@ -1,5 +1,5 @@
 /*
- *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *  Description     : This test is intended to verify that the primary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
@@ -9,18 +9,18 @@
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-secondary-58.adm";
+write output to nc1:"rttest/btree-index_btree-primary-58.adm";
 
 create type TestType as open {
     id : int32,
     fname : string,
     lname : string
 }
- 
+
 create dataset testdst(TestType) primary key id;
 
 create index sec_Idx on testdst(fname);
 
 for $emp in dataset('testdst') 
-where $emp.fname = "Max" 
+where $emp.fname > "Neil" and $emp.fname < "Roger" 
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-59.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-59.aql
index 2b0a300..b5b7022 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-59.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-59.aql
@@ -1,6 +1,5 @@
 /*
- *  Description     : BTree Index verification test
- *                  : This test is intended to verify that the secondary BTree index is used 
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
  *  Date            : 13th Aug 2012
@@ -10,7 +9,7 @@
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-secondary-49.adm";
+write output to nc1:"rttest/btree-index_btree-secondary-59.adm";
 
 create type TestType as open {
     id : int32,
@@ -18,11 +17,10 @@
     lname : string
 }
 
-// create internal dataset
-create dataset testdst(TestType)  primary key id;
+create dataset testdst(TestType) primary key id;
 
-create index sec_Idx on testdst(fname,lname);
+create index sec_Idx on testdst(fname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname < "Tomes"
+where $emp.fname >= "Max" and $emp.fname <= "Roger" 
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-60.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-60.aql
new file mode 100644
index 0000000..c32df0f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-60.aql
@@ -0,0 +1,26 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-60.adm";
+
+create type TestType as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+ 
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname);
+
+for $emp in dataset('testdst') 
+where $emp.fname = "Max" 
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-61.aql
similarity index 68%
copy from asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
copy to asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-61.aql
index 9f8ebc4..384a648 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-61.aql
@@ -6,13 +6,11 @@
  *  Date            : 13th Aug 2012
  */
 
-// Please note this is a Positive test and the BTree index should be used in the plan.
-
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-primary-31.adm";
+write output to nc1:"rttest/btree-index_btree-secondary-61.adm";
 
 create type TestType as open {
     id : int32,
@@ -20,10 +18,11 @@
     lname : string
 }
 
-create dataset testdst(TestType) primary key id;
+// create internal dataset
+create dataset testdst(TestType)  primary key id;
 
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Roger"
+where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname < "Tomes"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-62.aql
similarity index 71%
rename from asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
rename to asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-62.aql
index 9f8ebc4..4761469 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-62.aql
@@ -3,16 +3,16 @@
  *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
- *  Date            : 13th Aug 2012
+ *  Date            : 11th Nov 2014
  */
 
-// Please note this is a Positive test and the BTree index should be used in the plan.
+// Positive test - prefix search
 
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-primary-31.adm";
+write output to nc1:"rttest/btree-index_btree-secondary-62.adm";
 
 create type TestType as open {
     id : int32,
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Roger"
+where $emp.fname = "Julio" and $emp.lname > "Xu"
 return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-63.aql
similarity index 71%
copy from asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
copy to asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-63.aql
index 9f8ebc4..46b2283 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-31.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-secondary-63.aql
@@ -3,16 +3,16 @@
  *                  : This test is intended to verify that the secondary BTree index is used 
  *                  : in the optimized query plan.
  *  Expected Result : Success
- *  Date            : 13th Aug 2012
+ *  Date            : 11th Nov 2014
  */
 
-// Please note this is a Positive test and the BTree index should be used in the plan.
+// Positive test - prefix search
 
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
 
-write output to nc1:"rttest/btree-index_btree-primary-31.adm";
+write output to nc1:"rttest/btree-index_btree-secondary-63.adm";
 
 create type TestType as open {
     id : int32,
@@ -25,5 +25,5 @@
 create index sec_Idx on testdst(fname,lname);
 
 for $emp in dataset('testdst') 
-where $emp.fname > "Roger"
+where $emp.fname < "Julio" and $emp.lname = "Xu"
 return $emp