Fixed the classad-parser for Optional Fields

Change-Id: Ie231ed3ca7411ed7a48192bf6f3c6385d287323a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/794
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <hubailmor@gmail.com>
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
index 93b31ca..3c22241 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
@@ -385,6 +385,11 @@
                 throw new HyracksDataException("Unknown Expression type detected: " + tree.getKind());
         }
 
+        if (fieldType != null) {
+            if (NonTaggedFormatUtil.isOptional(fieldType)) {
+                fieldType = ((AUnionType) fieldType).getNullableType();
+            }
+        }
         switch (val.getValueType()) {
             case ABSOLUTE_TIME_VALUE:
                 if (checkType(ATypeTag.DATETIME, fieldType)) {