merge r1183:1187 (from asterix_stabilization)

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_issue_252_253@1188 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql b/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql
new file mode 100644
index 0000000..af39b3f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/q1_pricing_summary_report_nt.aql
@@ -0,0 +1,50 @@
+drop dataverse tpch if exists;
+create dataverse tpch;
+use dataverse tpch;
+
+create type LineItemType as closed {
+  l_orderkey: int32, 
+  l_partkey: int32, 
+  l_suppkey: int32, 
+  l_linenumber: int32, 
+  l_quantity: double, 
+  l_extendedprice: double,
+  l_discount: double, 
+  l_tax: double,
+  l_returnflag: string, 
+  l_linestatus: string, 
+  l_shipdate: string,
+  l_commitdate: string, 
+  l_receiptdate: string, 
+  l_shipinstruct: string, 
+  l_shipmode: string, 
+  l_comment: string
+}
+
+create dataset LineItem(LineItemType)
+  partitioned by key l_orderkey, l_linenumber;
+
+load dataset LineItem 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+write output to nc1:"rttest/tpch_q1_pricing_summary_report_nt.adm";
+ 
+for $l in dataset('LineItem')
+where $l.l_shipdate <= '1998-09-02'
+/*+ hash*/
+group by $l_returnflag := $l.l_returnflag, $l_linestatus := $l.l_linestatus  
+  with $l
+order by $l_returnflag, $l_linestatus
+return {
+  "l_returnflag": $l_returnflag,
+  "l_linestatus": $l_linestatus,
+  "sum_qty": sum(for $i in $l return $i.l_quantity),
+  "sum_base_price": sum(for $i in $l return $i.l_extendedprice),
+  "sum_disc_price": sum(for $i in $l return $i.l_extendedprice * (1 - $i.l_discount)),
+  "sum_charge": sum(for $i in $l return $i.l_extendedprice * (1 - $i.l_discount) * (1 + $i.l_tax)),
+  "ave_qty": avg(for $i in $l return $i.l_quantity),  
+  "ave_price": avg(for $i in $l return $i.l_extendedprice),
+  "ave_disc": avg(for $i in $l return $i.l_discount),
+  "count_order": count($l)
+}   
diff --git a/asterix-app/src/test/resources/optimizerts/results/q1_pricing_summary_report_nt.plan b/asterix-app/src/test/resources/optimizerts/results/q1_pricing_summary_report_nt.plan
new file mode 100644
index 0000000..676e6e2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/q1_pricing_summary_report_nt.plan
@@ -0,0 +1,25 @@
+-- SINK_WRITE  |PARTITIONED|
+  -- STREAM_PROJECT  |PARTITIONED|
+    -- ASSIGN  |PARTITIONED|
+      -- SORT_MERGE_EXCHANGE [$$1(ASC), $$2(ASC) ]  |PARTITIONED|
+        -- STABLE_SORT [$$1(ASC), $$2(ASC)]  |PARTITIONED|
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            -- EXTERNAL_GROUP_BY[$$74, $$75]  |PARTITIONED|
+                    {
+                      -- AGGREGATE  |LOCAL|
+                        -- NESTED_TUPLE_SOURCE  |LOCAL|
+                    }
+              -- HASH_PARTITION_EXCHANGE [$$74, $$75]  |PARTITIONED|
+                -- EXTERNAL_GROUP_BY[$$48, $$49]  |PARTITIONED|
+                        {
+                          -- AGGREGATE  |LOCAL|
+                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                        }
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- STREAM_SELECT  |PARTITIONED|
+                      -- ASSIGN  |PARTITIONED|
+                        -- STREAM_PROJECT  |PARTITIONED|
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            -- DATASOURCE_SCAN  |PARTITIONED|
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/create-drop-cltype.aql b/asterix-app/src/test/resources/runtimets/queries/dml/create-drop-cltype.aql
new file mode 100644
index 0000000..f6c6e91
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/create-drop-cltype.aql
@@ -0,0 +1,40 @@
+/*
+ * Description  : Create and drop and recreate the same closed type, here type has optional fields.
+ *              : verify correctness by querying metadata.
+ * Date         : 11th Feb 2013
+ * Expected Res : Success
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+id : int32,
+salary : double ?,
+name : string,
+durtn : duration ?,
+inter : interval,
+dt : date ?,
+tm : time,
+pt : point ?
+}
+
+drop type TestType;
+
+create type TestType as closed {
+id : int32,
+salary : double ?,
+name : string,
+durtn : duration ?,
+inter : interval,
+dt : date ?,
+tm : time,
+pt : point ?
+}
+
+write output to nc1:"rttest/dml_create-drop-cltype.adm";
+
+for $l in dataset('Metadata.Datatype')
+where $l.DatatypeName = 'TestType'
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/create-drop-opntype.aql b/asterix-app/src/test/resources/runtimets/queries/dml/create-drop-opntype.aql
new file mode 100644
index 0000000..0ef6e93
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/create-drop-opntype.aql
@@ -0,0 +1,40 @@
+/*
+ * Description  : Create and drop and recreate the same open type, here type has optional fields.
+ *              : verify correctness by querying metadata.
+ * Date         : 11th Feb 2013
+ * Expected Res : Success
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+id : int32,
+salary : double ?,
+name : string,
+durtn : duration ?,
+inter : interval,
+dt : date ?,
+tm : time,
+pt : point ?
+}
+
+drop type TestType;
+
+create type TestType as open {
+id : int32,
+salary : double ?,
+name : string,
+durtn : duration ?,
+inter : interval,
+dt : date ?,
+tm : time,
+pt : point ?
+}
+
+write output to nc1:"rttest/dml_create-drop-opntype.adm"; 
+
+for $l in dataset('Metadata.Datatype')
+where $l.DatatypeName = 'TestType'
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/create-drop-cltype.adm b/asterix-app/src/test/resources/runtimets/results/dml/create-drop-cltype.adm
new file mode 100644
index 0000000..e2f6676
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/dml/create-drop-cltype.adm
@@ -0,0 +1 @@
+{ "DataverseName": "test", "DatatypeName": "TestType", "Derived": { "Tag": "RECORD", "IsAnonymous": false, "EnumValues": null, "Record": { "IsOpen": false, "Fields": [ { "FieldName": "id", "FieldType": "int32" }, { "FieldName": "salary", "FieldType": "Field_salary_in_TestType" }, { "FieldName": "name", "FieldType": "string" }, { "FieldName": "durtn", "FieldType": "Field_durtn_in_TestType" }, { "FieldName": "inter", "FieldType": "interval" }, { "FieldName": "dt", "FieldType": "Field_dt_in_TestType" }, { "FieldName": "tm", "FieldType": "time" }, { "FieldName": "pt", "FieldType": "Field_pt_in_TestType" } ] }, "Union": null, "UnorderedList": null, "OrderedList": null }, "Timestamp": "Mon Feb 11 18:10:43 PST 2013" }
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/create-drop-opntype.adm b/asterix-app/src/test/resources/runtimets/results/dml/create-drop-opntype.adm
new file mode 100644
index 0000000..8c0b451
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/dml/create-drop-opntype.adm
@@ -0,0 +1 @@
+{ "DataverseName": "test", "DatatypeName": "TestType", "Derived": { "Tag": "RECORD", "IsAnonymous": false, "EnumValues": null, "Record": { "IsOpen": true, "Fields": [ { "FieldName": "id", "FieldType": "int32" }, { "FieldName": "salary", "FieldType": "Field_salary_in_TestType" }, { "FieldName": "name", "FieldType": "string" }, { "FieldName": "durtn", "FieldType": "Field_durtn_in_TestType" }, { "FieldName": "inter", "FieldType": "interval" }, { "FieldName": "dt", "FieldType": "Field_dt_in_TestType" }, { "FieldName": "tm", "FieldType": "time" }, { "FieldName": "pt", "FieldType": "Field_pt_in_TestType" } ] }, "Union": null, "UnorderedList": null, "OrderedList": null }, "Timestamp": "Mon Feb 11 18:12:10 PST 2013" }
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index e305220..6956e4b 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -759,6 +759,16 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
+      <compilation-unit name="create-drop-cltype">
+        <output-file compare="Text">create-drop-cltype.adm</output-file>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="create-drop-opntype">
+        <output-file compare="Text">create-drop-opntype.adm</output-file>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
       <compilation-unit name="empty-load-with-index">
         <output-file compare="Text">empty-load-with-index.adm</output-file>
       </compilation-unit>