merge asterix_stabilization r335:377 and asterix_opentype r377:378

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_opentype_mergeback_staging@379 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/logging.properties b/asterix-app/src/test/resources/logging.properties
index 4cf5545..deb88307 100644
--- a/asterix-app/src/test/resources/logging.properties
+++ b/asterix-app/src/test/resources/logging.properties
@@ -61,5 +61,5 @@
 # messages:
 
 #edu.uci.ics.asterix.level = FINE
-edu.uci.ics.algebricks.level = FINE
-edu.uci.ics.hyracks.level = INFO
+#edu.uci.ics.algebricks.level = FINE
+#edu.uci.ics.hyracks.level = INFO
diff --git a/asterix-app/src/test/resources/runtimets/ignore.txt b/asterix-app/src/test/resources/runtimets/ignore.txt
index 70bc44d..a850d3c 100644
--- a/asterix-app/src/test/resources/runtimets/ignore.txt
+++ b/asterix-app/src/test/resources/runtimets/ignore.txt
@@ -27,3 +27,4 @@
 open-closed/open-closed-30
 open-closed/heterog-list02
 open-closed/heterog-list03
+open-closed/c2c
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql
new file mode 100644
index 0000000..354757d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-w-optional.aql
@@ -0,0 +1,37 @@
+/*
+ * Testcase Name  : c2c-w-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+id:int32,
+description:string,
+name:string,
+optnl_fld:string?
+}
+
+create dataset T1(TestType) partitioned by key id;
+
+create dataset T2(TestType) partitioned by key id;
+
+insert into dataset T1({
+"id":1234,
+"description":"donut",
+"name":"Cake",
+"optnl_fld":"optional data goes here"
+}
+);
+
+insert into dataset T2(for $l in dataset("T1") return $l );
+
+for $d in dataset("T2")
+order by $d.id
+return $d
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql
new file mode 100644
index 0000000..9d4b90a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c-wo-optional.aql
@@ -0,0 +1,37 @@
+/*
+ * Testcase Name  : c2c-wo-optional.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ *                : The schema includes one optional field named optnl_fld.
+ *                : Note that the optional field in source dataset does not hold any data.
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+id:int32,
+description:string,
+name:string,
+optnl_fld:string?
+}
+
+create dataset T1(TestType) partitioned by key id;
+
+create dataset T2(TestType) partitioned by key id;
+
+insert into dataset T1({
+"id":1234,
+"description":"donut",
+"name":"Cake"
+}
+);
+
+insert into dataset T2(for $l in dataset("T1") return $l );
+
+for $d in dataset("T2")
+order by $d.id
+return $d
diff --git a/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql
new file mode 100644
index 0000000..83888f3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/open-closed/c2c.aql
@@ -0,0 +1,36 @@
+/*
+ * Testcase Name  : c2c.aql
+ * Description    : Insert data into target datase by doing a select on source dataset.
+ *                : Here both source and target datasets are internal datasets
+ * Success        : Yes
+ * Date           : 23rd May 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as closed {
+id:int32,
+description:string,
+name:string
+}
+
+// source dataset
+create dataset T1(TestType) partitioned by key id;
+
+// target dataset
+create dataset T2(TestType) partitioned by key id;
+
+insert into dataset T1({
+"id":1234,
+"description":"donut",
+"name":"Cake"
+}
+);
+
+insert into dataset T2(for $l in dataset("T1") return $l );
+
+for $d in dataset("T2")
+order by $d.id
+return $d
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java
index 4e77e0d..4ba5a4c 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java
@@ -27,7 +27,7 @@
     }
 
     public boolean isNullableType() {
-        return unionList.size() == 2 && unionList.get(0).equals(BuiltinType.ANULL);
+    	return unionList.size() == 2 && unionList.get(0).getTypeTag().equals(BuiltinType.ANULL.getTypeTag());
     }
 
     @Override