BTree primary index (composite key) usage tests
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@662 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql
new file mode 100644
index 0000000..63e1248
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-01.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for this predicate.
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Please note this is a Negative test and the BTree index should NOT 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-01.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index (composite key) defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname > "Roger"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql
new file mode 100644
index 0000000..88a50ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-02.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan.
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// This is a Negative test - prefix search, BTree index should not 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-02.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Susan"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql
new file mode 100644
index 0000000..4fd1926
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-03.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for the predicates that satisfy BTree index look up rule.
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test - prefix search, BTree index should not be used.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-03.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname < "Isa"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql
new file mode 100644
index 0000000..d9bf70f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-04.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan.
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test - prefix search, BTree index should not be used in query plan
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-04.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname <= "Vanpatten"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql
new file mode 100644
index 0000000..b3dfe80
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-05.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan.
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test - BTree index should NOT be used in query plan
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-05.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname != "Max"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql
new file mode 100644
index 0000000..f4dc44a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-06.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for the predicates that satisfy BTree index look up rule.
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test - prefix search, BTree index should NOT be used in the query plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-06.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname = "Julio"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql
new file mode 100644
index 0000000..770db27
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-07.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * 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
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-07.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.lname = "Kim"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql
new file mode 100644
index 0000000..6ab5c9a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-08.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used in the optimized query plan
+ * : predicate => where $emp.fname = "Young Seok" and $emp.lname = "Kim"
+ * 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-primary-08.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname = "Young Seok" and $emp.lname = "Kim"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql
new file mode 100644
index 0000000..7906bb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-09.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for predicates like (predicate 1 or predicate 2).
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-09.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname = "Julio" or $emp.lname = "Malaika"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql
new file mode 100644
index 0000000..14f68b5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-10.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for predicates like (predicate 1 and predicate 2).
+ * 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-primary-10.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname > "Alex" and $emp.lname < "Zach"
+return $emp
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
new file mode 100644
index 0000000..5b09c49
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-11.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for predicates like the one used in this test.
+ * 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-primary-11.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname > "Allan" and $emp.lname < "Zubi"
+return $emp
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
new file mode 100644
index 0000000..f2d52f3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-12.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for predicates like ($v1 > v2 and $v3 = v4)
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-12.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname > "Allan" and $emp.lname = "Xu"
+return $emp
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
new file mode 100644
index 0000000..d2463f5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-13.aql
@@ -0,0 +1,35 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for predicates like ( $V1 = V2 and $V3 < V4).
+ * Expected Result : Success
+ * Date : 13th Aug 2012
+ */
+
+// Negative test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-13.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+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-14.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
new file mode 100644
index 0000000..3a15220
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-14.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for predicates like ($v1 >= v2 and $v3 <= v4).
+ * 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-primary-14.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Michael" and $emp.lname <= "Xu"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql
new file mode 100644
index 0000000..255c11e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-15.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for predicates like (predicate1 and predicate2 and predicate3 and predicate4).
+ * 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-primary-15.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+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-primary-16.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-16.aql
new file mode 100644
index 0000000..fecece0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-16.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for predicates like (predicate1 and predicate2 and predicate3 and predicate4).
+ * 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-primary-16.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+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-primary-17.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
new file mode 100644
index 0000000..f15cee1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-17.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT used
+ * : in the optimized query plan for predicates like ($v1 <= v2 and $v3 > v4).
+ * 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-primary-17.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname <= "Craig" and $emp.lname > "Kevin"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql
new file mode 100644
index 0000000..89f4859
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-18.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is NOT 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-primary-18.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname != "Michael" and $emp.lname != "Carey"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql
new file mode 100644
index 0000000..19abd0d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-19.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for predicates like (predicate1 and predicate2 and predicate3 and predicate4).
+ * 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-primary-19.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+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-primary-20.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-20.aql
new file mode 100644
index 0000000..a991aab
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-20.aql
@@ -0,0 +1,33 @@
+/*
+ * Description : BTree Index verification (usage) test
+ * : This test is intended to verify that the primary BTree index is used
+ * : in the optimized query plan for predicates like (predicate1 and predicate2 and predicate3 and predicate4).
+ * 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-primary-20.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+// create internal dataset with primary index defined on fname,lname fields
+create dataset testdst(TestType) partitioned by key fname,lname;
+
+// load valid data with fname and lname entries
+
+load dataset testdst
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/fn-ln.adm"),("format"="delimited-text"),("delimiter"="|"));
+
+// Query the data that was loaded above.
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
+return $emp