asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [05/29] incubator-asterixdb git commit: Supports Left Outer Join and Left Outer Unnest in SQL++.
Date Sat, 04 Jun 2016 02:44:09 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast
index e69de29..2487b68 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/multiply_int8/multiply_int8.1.ast
@@ -0,0 +1,103 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      *
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      *
+      LiteralExpr [MISSING]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast
index e69de29..b6a0800 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_double/subtract_double.1.ast
@@ -0,0 +1,108 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast
index e69de29..607e329 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_float/subtract_float.1.ast
@@ -0,0 +1,108 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+      -
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast
index e69de29..a82b04c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int16/subtract_int16.1.ast
@@ -0,0 +1,108 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+      -
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast
index e69de29..1d60412 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int32/subtract_int32.1.ast
@@ -0,0 +1,108 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+      -
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast
index e69de29..91964c1 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int64/subtract_int64.1.ast
@@ -0,0 +1,108 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+      -
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast
index e69de29..dd072ac 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/subtract_int8/subtract_int8.1.ast
@@ -0,0 +1,108 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [result1]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result2]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall null.int16@1[
+        LiteralExpr [STRING] [2]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result3]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall null.int32@1[
+        LiteralExpr [STRING] [+3]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result4]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall null.int64@1[
+        LiteralExpr [STRING] [-4]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result5]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall null.float@1[
+        LiteralExpr [STRING] [-5.5f]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result6]
+    :
+    OperatorExpr [
+      FunctionCall null.int8@1[
+        LiteralExpr [STRING] [+1]
+      ]
+      -
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result7]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [result8]
+    :
+    OperatorExpr [
+      FunctionCall null.double@1[
+        LiteralExpr [STRING] [-6.5d]
+      ]
+      -
+      IndexAccessor [
+        OrderedListConstructor [
+          LiteralExpr [LONG] [1]
+        ]
+        Index:         LiteralExpr [LONG] [1]
+      ]
+    ]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
index e69de29..c272a7e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/numeric/unary-minus_null/unary-minus_null.1.ast
@@ -0,0 +1,13 @@
+Query:
+RecordConstructor [
+  (
+    LiteralExpr [STRING] [nullField]
+    :
+    NEGATIVE LiteralExpr [NULL]
+  )
+  (
+    LiteralExpr [STRING] [missingField]
+    :
+    NEGATIVE LiteralExpr [MISSING]
+  )
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast
index c6a14c7..e4278c4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.12.ast
@@ -18,7 +18,7 @@ Where
       ]
     ]
     Satifies [
-      FunctionCall TinySocial.is-null@1[
+      FunctionCall TinySocial.is-missing@1[
         FieldAccessor [
           Variable [ Name=$e ]
           Field=end-date

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast
index 0bc18b9..d82f5bd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.13.ast
@@ -19,7 +19,7 @@ Where
     ]
     Satifies [
       FunctionCall TinySocial.not@1[
-        FunctionCall TinySocial.is-null@1[
+        FunctionCall TinySocial.is-missing@1[
           FieldAccessor [
             Variable [ Name=$e ]
             Field=end-date

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 569e011..0c08ffd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -927,6 +927,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="double_missing">
+        <output-dir compare="Text">double_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="double_null">
         <output-dir compare="Text">double_null</output-dir>
       </compilation-unit>
@@ -942,6 +947,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="float_missing">
+        <output-dir compare="Text">float_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="float_null">
         <output-dir compare="Text">float_null</output-dir>
       </compilation-unit>
@@ -962,6 +972,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="int16_missing">
+        <output-dir compare="Text">int16_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="int16_null">
         <output-dir compare="Text">int16_null</output-dir>
       </compilation-unit>
@@ -972,6 +987,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="int32_missing">
+        <output-dir compare="Text">int32_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="int32_null">
         <output-dir compare="Text">int32_null</output-dir>
       </compilation-unit>
@@ -982,6 +1002,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="int64_missing">
+        <output-dir compare="Text">int64_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="int64_null">
         <output-dir compare="Text">int64_null</output-dir>
       </compilation-unit>
@@ -992,6 +1017,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="int8_missing">
+        <output-dir compare="Text">int8_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="int8_null">
         <output-dir compare="Text">int8_null</output-dir>
       </compilation-unit>
@@ -1024,6 +1054,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="comparison">
+      <compilation-unit name="string_missing">
+        <output-dir compare="Text">string_missing</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="comparison">
       <compilation-unit name="string_null">
         <output-dir compare="Text">string_null</output-dir>
       </compilation-unit>
@@ -2277,7 +2312,7 @@
     <test-case FilePath="global-aggregate">
       <compilation-unit name="q05_error">
         <output-dir compare="Text">q01</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unsupported type</expected-error>
+        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: The first argument should be a RECORD, but it is</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="global-aggregate">
@@ -3604,6 +3639,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="null-missing">
+      <compilation-unit name="comparison">
+        <output-dir compare="Text">comparison</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="null-missing">
       <compilation-unit name="field-access">
         <output-dir compare="Text">field-access</output-dir>
       </compilation-unit>
@@ -6704,6 +6744,16 @@
   </test-group>
   <test-group name="leftouterjoin">
     <test-case FilePath="leftouterjoin">
+      <compilation-unit name="loj-01-core">
+        <output-dir compare="Text">loj-01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="leftouterjoin">
+      <compilation-unit name="loj-01-sugar">
+        <output-dir compare="Text">loj-01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="leftouterjoin">
       <compilation-unit name="query_issue658">
         <output-dir compare="Text">query_issue658</output-dir>
       </compilation-unit>
@@ -7165,5 +7215,15 @@
         <output-dir compare="Text">insert-and-scan-dataset-with-index</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="unnest">
+      <compilation-unit name="left-outer-unnest">
+        <output-dir compare="Text">left-outer-unnest</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="unnest">
+      <compilation-unit name="left-outer-unnest-with-pos">
+        <output-dir compare="Text">left-outer-unnest-with-pos</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
 </test-suite>

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/TypeException.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/TypeException.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/TypeException.java
deleted file mode 100644
index f8795a4..0000000
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/TypeException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.common.exceptions;
-
-public class TypeException extends AsterixException {
-
-    /**
-     *
-     */
-    private static final long serialVersionUID = 6823056042083694786L;
-
-    public TypeException(String s) {
-        super(s);
-    }
-
-    public TypeException(Exception e) {
-        super(e);
-    }
-
-    public TypeException(String s, Exception e) {
-        super(s, e);
-    }
-
-    public TypeException() {
-        super();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
index 491bc70..1af6b80 100644
--- a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
@@ -540,13 +540,17 @@ public class TestExecutor {
                 }
                 expectedResultFile = expectedResultFileCtxs.get(queryCount.intValue()).getFile();
 
-                File actualResultFile = testCaseCtx.getActualResultFile(cUnit, new File(actualPath));
+                File actualResultFile = testCaseCtx.getActualResultFile(cUnit, expectedResultFile,
+                        new File(actualPath));
                 actualResultFile.getParentFile().mkdirs();
                 writeOutputToFile(actualResultFile, resultStream);
 
                 runScriptAndCompareWithResult(testFile, new PrintWriter(System.err), expectedResultFile,
                         actualResultFile);
                 queryCount.increment();
+
+                // Deletes the matched result file.
+                actualResultFile.getParentFile().delete();
                 break;
             case "mgx":
                 executeManagixCommand(statement);
@@ -642,7 +646,7 @@ public class TestExecutor {
                     resultStream = executeClusterStateQuery(fmt,
                             "http://" + host + ":" + port + Servlets.CLUSTER_STATE.getPath());
                     expectedResultFile = expectedResultFileCtxs.get(queryCount.intValue()).getFile();
-                    actualResultFile = testCaseCtx.getActualResultFile(cUnit, new File(actualPath));
+                    actualResultFile = testCaseCtx.getActualResultFile(cUnit, expectedResultFile, new File(actualPath));
                     actualResultFile.getParentFile().mkdirs();
                     writeOutputToFile(actualResultFile, resultStream);
                     runScriptAndCompareWithResult(testFile, new PrintWriter(System.err), expectedResultFile,
@@ -653,7 +657,7 @@ public class TestExecutor {
                 }
                 break;
             case "server": // (start <test server name> <port>
-                           // [<arg1>][<arg2>][<arg3>]...|stop (<port>|all))
+                               // [<arg1>][<arg2>][<arg3>]...|stop (<port>|all))
                 try {
                     lines = statement.trim().split("\n");
                     String[] command = lines[lines.length - 1].trim().split(" ");
@@ -701,7 +705,7 @@ public class TestExecutor {
                 }
                 break;
             case "lib": // expected format <dataverse-name> <library-name>
-                        // <library-directory>
+                            // <library-directory>
                         // TODO: make this case work well with entity names containing spaces by
                         // looking for \"
                 lines = statement.split("\n");

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
index 0630985..ec55cf0 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
@@ -326,8 +326,8 @@ public class JObjectUtil {
                 if (numberOfSchemaFields > 0) {
                     dis.readInt();
                     int nullBitMapOffset = 0;
-                    boolean hasNullableFields = NonTaggedFormatUtil.hasNullableField(recordType);
-                    if (hasNullableFields) {
+                    boolean hasOptionalFields = NonTaggedFormatUtil.hasOptionalField(recordType);
+                    if (hasOptionalFields) {
                         nullBitMapOffset = dis.getInputStream().getPosition();
                         dis.getInputStream();
                     } else {
@@ -337,7 +337,7 @@ public class JObjectUtil {
                         fieldOffsets[i] = dis.readInt();
                     }
                     for (int fieldNumber = 0; fieldNumber < numberOfSchemaFields; fieldNumber++) {
-                        if (hasNullableFields) {
+                        if (hasOptionalFields) {
                             byte b1 = recordBits[nullBitMapOffset + fieldNumber / 8];
                             int p = 1 << (7 - (fieldNumber % 8));
                             if ((b1 & p) == 0) {
@@ -349,7 +349,7 @@ public class JObjectUtil {
 
                         IAType fieldType = fieldTypes[fieldNumber];
                         if (fieldTypes[fieldNumber].getTypeTag() == ATypeTag.UNION) {
-                            if (((AUnionType) fieldTypes[fieldNumber]).isNullableType()) {
+                            if (((AUnionType) fieldTypes[fieldNumber]).isUnknownableType()) {
                                 fieldType = ((AUnionType) fieldTypes[fieldNumber]).getActualType();
                                 fieldValueTypeTag = fieldType.getTypeTag();
                             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
index 0ad7be1..58d7c83 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
@@ -48,7 +48,6 @@ import org.apache.asterix.om.types.AUnorderedListType;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.asterix.om.types.hierachy.ITypeConvertComputer;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
 import org.apache.asterix.om.util.container.IObjectPool;
 import org.apache.asterix.om.util.container.ListObjectPool;
 import org.apache.asterix.runtime.operators.file.adm.AdmLexer;
@@ -485,7 +484,6 @@ public class ADMDataParser extends AbstractDataParser implements IStreamDataPars
             } else {
                 return null;
             }
-            // return ATypeHierarchy.canPromote(expectedTypeTag, typeTag) ? typeTag : null;
         } else { // union
             List<IAType> unionList = ((AUnionType) aObjectType).getUnionList();
             for (IAType t : unionList) {
@@ -579,13 +577,7 @@ public class ADMDataParser extends AbstractDataParser implements IStreamDataPars
                     token = admLexer.next();
                     this.admFromLexerStream(token, fieldType, fieldValueBuffer.getDataOutput());
                     if (openRecordField) {
-                        if (fieldValueBuffer.getByteArray()[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
-                            recBuilder.addField(fieldNameBuffer, fieldValueBuffer);
-                        }
-                    } else if (NonTaggedFormatUtil.isOptional(recType)) {
-                        if (fieldValueBuffer.getByteArray()[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
-                            recBuilder.addField(fieldId, fieldValueBuffer);
-                        }
+                        recBuilder.addField(fieldNameBuffer, fieldValueBuffer);
                     } else {
                         recBuilder.addField(fieldId, fieldValueBuffer);
                     }
@@ -611,7 +603,7 @@ public class ADMDataParser extends AbstractDataParser implements IStreamDataPars
         } while (inRecord);
 
         if (recType != null) {
-            nullableFieldId = checkNullConstraints(recType, nulls);
+            nullableFieldId = checkOptionalConstraints(recType, nulls);
             if (nullableFieldId != -1) {
                 throw new ParseException("Field: " + recType.getFieldNames()[nullableFieldId] + " can not be null");
             }
@@ -619,7 +611,7 @@ public class ADMDataParser extends AbstractDataParser implements IStreamDataPars
         recBuilder.write(out, true);
     }
 
-    private int checkNullConstraints(ARecordType recType, BitSet nulls) {
+    private int checkOptionalConstraints(ARecordType recType, BitSet nulls) {
         for (int i = 0; i < recType.getFieldTypes().length; i++) {
             if (nulls.get(i) == false) {
                 IAType type = recType.getFieldTypes()[i];
@@ -632,7 +624,7 @@ public class ADMDataParser extends AbstractDataParser implements IStreamDataPars
                 }
                 // union
                 AUnionType unionType = (AUnionType) type;
-                if (!unionType.isNullableType()) {
+                if (!unionType.isUnknownableType()) {
                     return i;
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
index 1df4e42..e33949e 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
@@ -163,7 +163,7 @@ public class ExternalDataUtils {
             ATypeTag tag = null;
             if (recordType.getFieldTypes()[i].getTypeTag() == ATypeTag.UNION) {
                 AUnionType unionType = (AUnionType) recordType.getFieldTypes()[i];
-                if (!unionType.isNullableType()) {
+                if (!unionType.isUnknownableType()) {
                     throw new NotImplementedException("Non-optional UNION type is not supported.");
                 }
                 tag = unionType.getActualType().getTypeTag();

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
----------------------------------------------------------------------
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 923163f..48cbeb2 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
@@ -352,10 +352,10 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
         }
 
         if (recType != null) {
-            int nullableFieldId = checkNullConstraints(recType, nulls);
-            if (nullableFieldId != -1) {
+            int optionalFieldId = checkOptionalConstraints(recType, nulls);
+            if (optionalFieldId != -1) {
                 throw new HyracksDataException(
-                        "Field: " + recType.getFieldNames()[nullableFieldId] + " can not be null");
+                        "Field: " + recType.getFieldNames()[optionalFieldId] + " can not be optional");
             }
         }
         recBuilder.write(out, true);
@@ -621,7 +621,7 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
         return objectPool.bitSetPool.get();
     }
 
-    public static int checkNullConstraints(ARecordType recType, BitSet nulls) {
+    public static int checkOptionalConstraints(ARecordType recType, BitSet nulls) {
         for (int i = 0; i < recType.getFieldTypes().length; i++) {
             if (nulls.get(i) == false) {
                 IAType type = recType.getFieldTypes()[i];
@@ -631,7 +631,7 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
 
                 if (type.getTypeTag() == ATypeTag.UNION) { // union
                     AUnionType unionType = (AUnionType) type;
-                    if (!unionType.isNullableType()) {
+                    if (!unionType.isUnknownableType()) {
                         return i;
                     }
                 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordTypeDefinition.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordTypeDefinition.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordTypeDefinition.java
index 5a6ce10..5e5208e 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordTypeDefinition.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordTypeDefinition.java
@@ -19,6 +19,7 @@
 package org.apache.asterix.lang.common.expression;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.asterix.common.annotations.IRecordFieldDataGen;
 import org.apache.asterix.common.annotations.UndeclaredFieldsDataGen;
@@ -35,15 +36,15 @@ public class RecordTypeDefinition extends TypeExpression {
     private ArrayList<String> fieldNames;
     private ArrayList<TypeExpression> fieldTypes;
     private ArrayList<IRecordFieldDataGen> fieldDataGen;
-    private ArrayList<Boolean> nullableFields;
+    private ArrayList<Boolean> optionalFields;
     private RecordKind recordKind;
     private UndeclaredFieldsDataGen undeclaredFieldsDataGen;
 
     public RecordTypeDefinition() {
-        fieldNames = new ArrayList<String>();
-        fieldTypes = new ArrayList<TypeExpression>();
-        nullableFields = new ArrayList<Boolean>();
-        fieldDataGen = new ArrayList<IRecordFieldDataGen>();
+        fieldNames = new ArrayList<>();
+        fieldTypes = new ArrayList<>();
+        optionalFields = new ArrayList<>();
+        fieldDataGen = new ArrayList<>();
     }
 
     @Override
@@ -54,29 +55,29 @@ public class RecordTypeDefinition extends TypeExpression {
     public void addField(String name, TypeExpression type, Boolean nullable, IRecordFieldDataGen fldDataGen) {
         fieldNames.add(name);
         fieldTypes.add(type);
-        nullableFields.add(nullable);
+        optionalFields.add(nullable);
         fieldDataGen.add(fldDataGen);
     }
 
-    public void addField(String name, TypeExpression type, Boolean nullable) {
+    public void addField(String name, TypeExpression type, Boolean optional) {
         fieldNames.add(name);
         fieldTypes.add(type);
-        nullableFields.add(nullable);
+        optionalFields.add(optional);
     }
 
-    public ArrayList<String> getFieldNames() {
+    public List<String> getFieldNames() {
         return fieldNames;
     }
 
-    public ArrayList<TypeExpression> getFieldTypes() {
+    public List<TypeExpression> getFieldTypes() {
         return fieldTypes;
     }
 
-    public ArrayList<Boolean> getNullableFields() {
-        return nullableFields;
+    public List<Boolean> getOptionableFields() {
+        return optionalFields;
     }
 
-    public ArrayList<IRecordFieldDataGen> getFieldDataGen() {
+    public List<IRecordFieldDataGen> getFieldDataGen() {
         return fieldDataGen;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
index b332df3..b9c583d 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
@@ -412,7 +412,7 @@ public class FormatPrintVisitor implements ILangVisitor<Void, Integer> {
         out.println("{");
         Iterator<String> nameIter = r.getFieldNames().iterator();
         Iterator<TypeExpression> typeIter = r.getFieldTypes().iterator();
-        Iterator<Boolean> isnullableIter = r.getNullableFields().iterator();
+        Iterator<Boolean> isOptionalIter = r.getOptionableFields().iterator();
         boolean first = true;
         while (nameIter.hasNext()) {
             if (first) {
@@ -422,7 +422,7 @@ public class FormatPrintVisitor implements ILangVisitor<Void, Integer> {
             }
             String name = normalize(nameIter.next());
             TypeExpression texp = typeIter.next();
-            Boolean isNullable = isnullableIter.next();
+            Boolean isNullable = isOptionalIter.next();
             out.print(skip(step) + name + " : ");
             texp.accept(this, step + 2);
             if (isNullable) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
index ceb45bb..ba2f52c 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
@@ -340,7 +340,7 @@ public class QueryPrintVisitor extends AbstractQueryExpressionVisitor<Void, Inte
         out.println("RecordType {");
         Iterator<String> nameIter = r.getFieldNames().iterator();
         Iterator<TypeExpression> typeIter = r.getFieldTypes().iterator();
-        Iterator<Boolean> isnullableIter = r.getNullableFields().iterator();
+        Iterator<Boolean> isOptionalIter = r.getOptionableFields().iterator();
         boolean first = true;
         while (nameIter.hasNext()) {
             if (first) {
@@ -350,7 +350,7 @@ public class QueryPrintVisitor extends AbstractQueryExpressionVisitor<Void, Inte
             }
             String name = nameIter.next();
             TypeExpression texp = typeIter.next();
-            Boolean isNullable = isnullableIter.next();
+            Boolean isNullable = isOptionalIter.next();
             out.print(skip(step + 1) + name + " : ");
             texp.accept(this, step + 2);
             if (isNullable) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
index 620461b..4c636d5 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
@@ -227,7 +227,7 @@ public final class MetadataRecordTypes {
                 "DatasourceAdapter", "Properties", "Function", "Status", "CompactionPolicy",
                 "CompactionPolicyProperties" };
 
-        IAType feedFunctionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
+        IAType feedFunctionUnion = AUnionType.createUnknownableType(BuiltinType.ASTRING);
 
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, orderedListType, orderedListType,
                 BuiltinType.ASTRING, BuiltinType.ASTRING, orderedListOfPropertiesType, feedFunctionUnion,
@@ -257,8 +257,8 @@ public final class MetadataRecordTypes {
                 "GroupName", "CompactionPolicy", "CompactionPolicyProperties", "InternalDetails", "ExternalDetails",
                 "Hints", "Timestamp", "DatasetId", "PendingOp" };
 
-        IAType internalRecordUnion = AUnionType.createNullableType(INTERNAL_DETAILS_RECORDTYPE);
-        IAType externalRecordUnion = AUnionType.createNullableType(EXTERNAL_DETAILS_RECORDTYPE);
+        IAType internalRecordUnion = AUnionType.createUnknownableType(INTERNAL_DETAILS_RECORDTYPE);
+        IAType externalRecordUnion = AUnionType.createUnknownableType(EXTERNAL_DETAILS_RECORDTYPE);
         AOrderedListType compactionPolicyPropertyListType = new AOrderedListType(
                 COMPACTION_POLICY_PROPERTIES_RECORDTYPE, null);
 
@@ -305,8 +305,8 @@ public final class MetadataRecordTypes {
 
     private static final ARecordType createDerivedTypeRecordType() throws AsterixException {
         String[] fieldNames = { "Tag", "IsAnonymous", "Record", "UnorderedList", "OrderedList" };
-        IAType recordUnion = AUnionType.createNullableType(RECORD_RECORDTYPE);
-        IAType collectionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
+        IAType recordUnion = AUnionType.createUnknownableType(RECORD_RECORDTYPE);
+        IAType collectionUnion = AUnionType.createUnknownableType(BuiltinType.ASTRING);
 
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ABOOLEAN, recordUnion, collectionUnion,
                 collectionUnion };
@@ -322,7 +322,7 @@ public final class MetadataRecordTypes {
 
     private static final ARecordType createDatatypeRecordType() throws AsterixException {
         String[] fieldNames = { "DataverseName", "DatatypeName", "Derived", "Timestamp" };
-        IAType recordUnion = AUnionType.createNullableType(DERIVEDTYPE_RECORDTYPE);
+        IAType recordUnion = AUnionType.createUnknownableType(DERIVEDTYPE_RECORDTYPE);
         IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, recordUnion, BuiltinType.ASTRING };
         return new ARecordType("DatatypeRecordType", fieldNames, fieldTypes, true);
     };
@@ -435,9 +435,9 @@ public final class MetadataRecordTypes {
 
     private static ARecordType createFeedRecordType() throws AsterixException, HyracksDataException {
 
-        IAType feedFunctionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
-        IAType primaryRecordUnion = AUnionType.createNullableType(PRIMARY_FEED_DETAILS_RECORDTYPE);
-        IAType secondaryRecordUnion = AUnionType.createNullableType(SECONDARY_FEED_DETAILS_RECORDTYPE);
+        IAType feedFunctionUnion = AUnionType.createUnknownableType(BuiltinType.ASTRING);
+        IAType primaryRecordUnion = AUnionType.createUnknownableType(PRIMARY_FEED_DETAILS_RECORDTYPE);
+        IAType secondaryRecordUnion = AUnionType.createUnknownableType(SECONDARY_FEED_DETAILS_RECORDTYPE);
 
         String[] fieldNames = { "DataverseName", "FeedName", "Function", "FeedType", "PrimaryTypeDetails",
                 "SecondaryTypeDetails", "Timestamp" };

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
index 323ea6d..f2e0424 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
@@ -560,7 +560,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
 
     public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> buildBtreeRuntime(JobSpecification jobSpec,
             List<LogicalVariable> outputVars, IOperatorSchema opSchema, IVariableTypeEnvironment typeEnv,
-            JobGenContext context, boolean retainInput, boolean retainNull, Dataset dataset, String indexName,
+            JobGenContext context, boolean retainInput, boolean retainMissing, Dataset dataset, String indexName,
             int[] lowKeyFields, int[] highKeyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
             Object implConfig, int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes) throws AlgebricksException {
 
@@ -671,7 +671,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
                                 rtcProvider, LSMBTreeIOOperationCallbackFactory.INSTANCE,
                                 storageProperties.getBloomFilterFalsePositiveRate(), !isSecondary, filterTypeTraits,
                                 filterCmpFactories, btreeFields, filterFields, !temp),
-                        retainInput, retainNull, context.getNullWriterFactory(), searchCallbackFactory,
+                        retainInput, retainMissing, context.getMissingWriterFactory(), searchCallbackFactory,
                         minFilterFieldIndexes, maxFilterFieldIndexes);
             } else {
                 // External dataset <- use the btree with buddy btree->
@@ -687,7 +687,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
                 btreeSearchOp = new ExternalBTreeSearchOperatorDescriptor(jobSpec, outputRecDesc, rtcProvider,
                         rtcProvider, spPc.first, typeTraits, comparatorFactories, bloomFilterKeyFields, lowKeyFields,
                         highKeyFields, lowKeyInclusive, highKeyInclusive, indexDataflowHelperFactory, retainInput,
-                        retainNull, context.getNullWriterFactory(), searchCallbackFactory);
+                        retainMissing, context.getMissingWriterFactory(), searchCallbackFactory);
             }
 
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeSearchOp, spPc.second);
@@ -744,7 +744,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
 
     public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> buildRtreeRuntime(JobSpecification jobSpec,
             List<LogicalVariable> outputVars, IOperatorSchema opSchema, IVariableTypeEnvironment typeEnv,
-            JobGenContext context, boolean retainInput, boolean retainNull, Dataset dataset, String indexName,
+            JobGenContext context, boolean retainInput, boolean retainMissing, Dataset dataset, String indexName,
             int[] keyFields, int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes) throws AlgebricksException {
 
         try {
@@ -835,8 +835,8 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
                         rtreeFields, filterTypeTraits, filterCmpFactories, filterFields, !temp, isPointMBR);
                 rtreeSearchOp = new RTreeSearchOperatorDescriptor(jobSpec, outputRecDesc,
                         appContext.getStorageManagerInterface(), appContext.getIndexLifecycleManagerProvider(),
-                        spPc.first, typeTraits, comparatorFactories, keyFields, idff, retainInput, retainNull,
-                        context.getNullWriterFactory(), searchCallbackFactory, minFilterFieldIndexes,
+                        spPc.first, typeTraits, comparatorFactories, keyFields, idff, retainInput, retainMissing,
+                        context.getMissingWriterFactory(), searchCallbackFactory, minFilterFieldIndexes,
                         maxFilterFieldIndexes);
             } else {
                 // External Dataset
@@ -853,7 +853,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
                 rtreeSearchOp = new ExternalRTreeSearchOperatorDescriptor(jobSpec, outputRecDesc,
                         appContext.getStorageManagerInterface(), appContext.getIndexLifecycleManagerProvider(),
                         spPc.first, typeTraits, comparatorFactories, keyFields, indexDataflowHelperFactory, retainInput,
-                        retainNull, context.getNullWriterFactory(), searchCallbackFactory);
+                        retainMissing, context.getMissingWriterFactory(), searchCallbackFactory);
             }
 
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(rtreeSearchOp, spPc.second);
@@ -2166,7 +2166,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
     public static Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> buildExternalDataLookupRuntime(
             JobSpecification jobSpec, Dataset dataset, Index secondaryIndex, int[] ridIndexes, boolean retainInput,
             IVariableTypeEnvironment typeEnv, List<LogicalVariable> outputVars, IOperatorSchema opSchema,
-            JobGenContext context, AqlMetadataProvider metadataProvider, boolean retainNull)
+            JobGenContext context, AqlMetadataProvider metadataProvider, boolean retainMissing)
             throws AlgebricksException {
         try {
             // Get data type
@@ -2178,8 +2178,8 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
             // a map->
             ExternalDatasetDetails datasetDetails = (ExternalDatasetDetails) dataset.getDatasetDetails();
             LookupAdapterFactory<?> adapterFactory = AdapterFactoryProvider.getLookupAdapterFactory(
-                    datasetDetails.getProperties(), (ARecordType) itemType, ridIndexes, retainInput, retainNull,
-                    context.getNullWriterFactory());
+                    datasetDetails.getProperties(), (ARecordType) itemType, ridIndexes, retainInput, retainMissing,
+                    context.getMissingWriterFactory());
 
             Pair<ILSMMergePolicyFactory, Map<String, String>> compactionInfo;
             try {
@@ -2211,7 +2211,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
                     outRecDesc, indexDataflowHelperFactory, retainInput, appContext.getIndexLifecycleManagerProvider(),
                     appContext.getStorageManagerInterface(), spPc.first, dataset.getDatasetId(),
                     metadataProvider.getStorageProperties().getBloomFilterFalsePositiveRate(), searchOpCallbackFactory,
-                    retainNull, context.getNullWriterFactory());
+                    retainMissing, context.getMissingWriterFactory());
 
             // Return value
             return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(op, spPc.second);
@@ -2345,7 +2345,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId, Strin
             op = new AsterixLSMTreeUpsertOperatorDescriptor(spec, outputRecordDesc,
                     appContext.getStorageManagerInterface(), appContext.getIndexLifecycleManagerProvider(),
                     splitsAndConstraint.first, typeTraits, comparatorFactories, bloomFilterKeyFields, fieldPermutation,
-                    idfh, null, true, indexName, context.getNullWriterFactory(), modificationCallbackFactory,
+                    idfh, null, true, indexName, context.getMissingWriterFactory(), modificationCallbackFactory,
                     searchCallbackFactory, null);
             op.setType(itemType);
             op.setFilterIndex(fieldIdx);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
index 8cd3d05..e3f439c 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
@@ -35,7 +35,7 @@ import org.apache.asterix.om.types.IAType;
  */
 public class AsterixBuiltinTypeMap {
 
-    private static final Map<String, BuiltinType> _builtinTypeMap = new HashMap<String, BuiltinType>();
+    private static final Map<String, BuiltinType> _builtinTypeMap = new HashMap<>();
 
     static {
         _builtinTypeMap.put("int8", BuiltinType.AINT8);
@@ -66,12 +66,16 @@ public class AsterixBuiltinTypeMap {
         _builtinTypeMap.put("shortwithouttypeinfo", BuiltinType.SHORTWITHOUTTYPEINFO);
     }
 
+    private AsterixBuiltinTypeMap() {
+
+    }
+
     public static Map<String, BuiltinType> getBuiltinTypes() {
         return _builtinTypeMap;
     }
 
     public static IAType getTypeFromTypeName(MetadataNode metadataNode, JobId jobId, String dataverseName,
-            String typeName, boolean isNullable) throws MetadataException {
+            String typeName, boolean optional) throws MetadataException {
         IAType type = AsterixBuiltinTypeMap.getBuiltinTypes().get(typeName);
         if (type == null) {
             try {
@@ -81,8 +85,8 @@ public class AsterixBuiltinTypeMap {
                 throw new MetadataException(e);
             }
         }
-        if (isNullable) {
-            type = AUnionType.createNullableType(type);
+        if (optional) {
+            type = AUnionType.createUnknownableType(type);
         }
         return type;
     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
index 955249c..fc82255 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/FeedTupleTranslator.java
@@ -39,6 +39,7 @@ import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
 import org.apache.asterix.metadata.bootstrap.MetadataRecordTypes;
 import org.apache.asterix.metadata.entities.Feed;
+import org.apache.asterix.om.base.AMissing;
 import org.apache.asterix.om.base.AMutableString;
 import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.ARecord;
@@ -93,7 +94,7 @@ public class FeedTupleTranslator extends AbstractTupleTranslator<Feed> {
 
         Object o = feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_FUNCTION_FIELD_INDEX);
         FunctionSignature signature = null;
-        if (!(o instanceof ANull)) {
+        if (!(o instanceof ANull) && !(o instanceof AMissing)) {
             String functionName = ((AString) o).getStringValue();
             signature = new FunctionSignature(dataverseName, functionName, 1);
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
index a2b16dd..bb79ea2 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
@@ -71,9 +71,6 @@ public abstract class AbstractListBuilder implements IAsterixListBuilder {
         }
         headerSize = 2;
         metadataInfoSize = 8;
-        if (itemTypeTag == ATypeTag.MISSING) {
-            itemTypeTag = ATypeTag.NULL;
-        }
     }
 
     @Override
@@ -84,20 +81,16 @@ public abstract class AbstractListBuilder implements IAsterixListBuilder {
             int len = item.getLength();
 
             byte serializedTypeTag = data[start];
-            if (serializedTypeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
-                // NULL in a list is MISSING.
-                serializedTypeTag = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
-            }
-
-            if (!fixedSize && (serializedTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG || itemTypeTag == ATypeTag.ANY)) {
+            if (!fixedSize && ((serializedTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                    && serializedTypeTag != ATypeTag.SERIALIZED_MISSING_TYPE_TAG) || itemTypeTag == ATypeTag.ANY)) {
                 this.offsets.add(outputStorage.getLength());
             }
-            if (itemTypeTag == ATypeTag.ANY
-                    || (itemTypeTag == ATypeTag.NULL && serializedTypeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
+            if (toWriteTag(serializedTypeTag)) {
                 this.numberOfItems++;
                 this.outputStream.write(serializedTypeTag);
                 this.outputStream.write(data, start + 1, len - 1);
-            } else if (serializedTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+            } else if (serializedTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                    && serializedTypeTag != ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
                 this.numberOfItems++;
                 this.outputStream.write(data, start + 1, len - 1);
             }
@@ -106,6 +99,14 @@ public abstract class AbstractListBuilder implements IAsterixListBuilder {
         }
     }
 
+    private boolean toWriteTag(byte serializedTypeTag) {
+        boolean toWriteTag = itemTypeTag == ATypeTag.ANY;
+        toWriteTag = toWriteTag
+                || (itemTypeTag == ATypeTag.NULL && serializedTypeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+        return toWriteTag
+                || (itemTypeTag == ATypeTag.MISSING && serializedTypeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+    }
+
     @Override
     public void write(DataOutput out, boolean writeTypeTag) throws HyracksDataException {
         try {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
index bfe08da..7e6d97e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
@@ -50,7 +50,7 @@ public class RecordBuilder implements IARecordBuilder {
     private int offsetPosition;
     private int headerSize;
     private boolean isOpen;
-    private boolean isNullable;
+    private boolean containsOptionalField;
     private int numberOfSchemaFields;
 
     private int openPartOffset;
@@ -101,7 +101,10 @@ public class RecordBuilder implements IARecordBuilder {
         this.numberOfOpenFields = 0;
         this.offsetPosition = 0;
         if (nullBitMap != null) {
-            Arrays.fill(nullBitMap, (byte) 0);
+            // A default null byte is 10101010 (0xAA):
+            // the null bit is 1, which means the field is not a null,
+            // the missing bit is 0, means the field is missing (by default).
+            Arrays.fill(nullBitMap, (byte) 0xAA);
         }
     }
 
@@ -116,11 +119,11 @@ public class RecordBuilder implements IARecordBuilder {
         this.offsetPosition = 0;
         if (recType != null) {
             this.isOpen = recType.isOpen();
-            this.isNullable = NonTaggedFormatUtil.hasNullableField(recType);
+            this.containsOptionalField = NonTaggedFormatUtil.hasOptionalField(recType);
             this.numberOfSchemaFields = recType.getFieldNames().length;
         } else {
             this.isOpen = true;
-            this.isNullable = false;
+            this.containsOptionalField = false;
             this.numberOfSchemaFields = 0;
         }
         // the header of the record consists of tag + record length (in bytes) +
@@ -145,41 +148,60 @@ public class RecordBuilder implements IARecordBuilder {
                 closedPartOffsets = new int[numberOfSchemaFields];
             }
 
-            if (isNullable) {
-                nullBitMapSize = (int) Math.ceil(numberOfSchemaFields / 8.0);
+            if (containsOptionalField) {
+                nullBitMapSize = (int) Math.ceil(numberOfSchemaFields / 4.0);
                 if (nullBitMap == null || nullBitMap.length < nullBitMapSize) {
                     this.nullBitMap = new byte[nullBitMapSize];
                 }
-                Arrays.fill(nullBitMap, 0, nullBitMapSize, (byte) 0);
+                // A default null byte is 10101010 (0xAA):
+                // the null bit is 1, which means the field is not a null,
+                // the missing bit is 0, means the field is missing (by default).
+                Arrays.fill(nullBitMap, 0, nullBitMapSize, (byte) 0xAA);
                 headerSize += nullBitMap.length;
             }
         }
     }
 
     @Override
-    public void addField(int id, IValueReference value) {
-        closedPartOffsets[id] = closedPartOutputStream.size();
+    public void addField(int fid, IValueReference value) {
+        closedPartOffsets[fid] = closedPartOutputStream.size();
         int len = value.getLength() - 1;
         // +1 because we do not store the value tag.
         closedPartOutputStream.write(value.getByteArray(), value.getStartOffset() + 1, len);
         numberOfClosedFields++;
-        if (isNullable && value.getByteArray()[value.getStartOffset()] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
-            nullBitMap[id / 8] |= (byte) (1 << (7 - (id % 8)));
-        }
+        addNullOrMissingField(fid, value.getByteArray(), value.getStartOffset());
     }
 
-    public void addField(int id, byte[] value) {
-        closedPartOffsets[id] = closedPartOutputStream.size();
+    public void addField(int fid, byte[] value) {
+        closedPartOffsets[fid] = closedPartOutputStream.size();
         // We assume the tag is not included (closed field)
         closedPartOutputStream.write(value, 0, value.length);
         numberOfClosedFields++;
-        if (isNullable && value[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
-            nullBitMap[id / 8] |= (byte) (1 << (7 - (id % 8)));
+        addNullOrMissingField(fid, value, 0);
+    }
+
+    private void addNullOrMissingField(int fid, byte[] data, int offset) {
+        if (containsOptionalField) {
+            byte nullByte = (byte) (1 << (7 - 2 * (fid % 4)));
+            if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                // unset the null bit, 0 means is null.
+                nullBitMap[fid / 4] &= ~nullByte;
+            }
+            if (data[offset] != ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+                nullBitMap[fid / 4] |= (byte) (1 << (7 - 2 * (fid % 4) - 1));
+            }
         }
     }
 
     @Override
     public void addField(IValueReference name, IValueReference value) throws HyracksDataException {
+        byte[] data = value.getByteArray();
+        int offset = value.getStartOffset();
+
+        // MISSING for an open field means the field does not exist.
+        if (data[offset] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+            return;
+        }
         if (numberOfOpenFields == openPartOffsets.length) {
             openPartOffsets = Arrays.copyOf(openPartOffsets, openPartOffsets.length + DEFAULT_NUM_OPEN_FIELDS);
             openFieldNameLengths = Arrays.copyOf(openFieldNameLengths,
@@ -196,7 +218,7 @@ public class RecordBuilder implements IARecordBuilder {
             }
         }
         openPartOffsets[this.numberOfOpenFields] = fieldNameHashCode;
-        openPartOffsets[this.numberOfOpenFields] = (openPartOffsets[numberOfOpenFields] << 32);
+        openPartOffsets[this.numberOfOpenFields] = openPartOffsets[numberOfOpenFields] << 32;
         openPartOffsets[numberOfOpenFields] += openPartOutputStream.size();
         openFieldNameLengths[numberOfOpenFields++] = name.getLength() - 1;
         openPartOutputStream.write(name.getByteArray(), name.getStartOffset() + 1, name.getLength() - 1);
@@ -267,7 +289,7 @@ public class RecordBuilder implements IARecordBuilder {
             // write the closed part
             if (numberOfSchemaFields > 0) {
                 out.writeInt(numberOfClosedFields);
-                if (isNullable) {
+                if (containsOptionalField) {
                     out.write(nullBitMap, 0, nullBitMapSize);
                 }
                 for (int i = 0; i < numberOfSchemaFields; i++) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
index 313f821..38af613 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
@@ -36,7 +36,7 @@ public class AqlMissingWriterFactory implements IMissingWriterFactory {
 
     @Override
     public IMissingWriter createMissingWriter() {
-        return out -> writeMissing(out);
+        return AqlMissingWriterFactory::writeMissing;
     }
 
     private static void writeMissing(DataOutput out) throws HyracksDataException {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/b0fe0ac0/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
index 0312ec0..c922054 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
@@ -29,6 +29,7 @@ import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
 import org.apache.asterix.formats.nontagged.AqlBinaryHashFunctionFactoryProvider;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AMissing;
 import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.ARecord;
 import org.apache.asterix.om.base.IAObject;
@@ -108,10 +109,10 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
             IAObject[] closedFields = null;
             if (numberOfSchemaFields > 0) {
                 in.readInt(); // read number of closed fields.
-                boolean hasNullableFields = NonTaggedFormatUtil.hasNullableField(this.recordType);
+                boolean hasOptionalFields = NonTaggedFormatUtil.hasOptionalField(this.recordType);
                 byte[] nullBitMap = null;
-                if (hasNullableFields) {
-                    int nullBitMapSize = (int) (Math.ceil(numberOfSchemaFields / 8.0));
+                if (hasOptionalFields) {
+                    int nullBitMapSize = (int) (Math.ceil(numberOfSchemaFields / 4.0));
                     nullBitMap = new byte[nullBitMapSize];
                     in.readFully(nullBitMap);
                 }
@@ -120,10 +121,14 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
                     in.readInt();
                 }
                 for (int fieldId = 0; fieldId < numberOfSchemaFields; fieldId++) {
-                    if (hasNullableFields && ((nullBitMap[fieldId / 8] & (1 << (7 - (fieldId % 8)))) == 0)) {
+                    if (hasOptionalFields && ((nullBitMap[fieldId / 4] & (1 << (7 - 2 * (fieldId % 4)))) == 0)) {
                         closedFields[fieldId] = ANull.NULL;
                         continue;
                     }
+                    if (hasOptionalFields && ((nullBitMap[fieldId / 4] & (1 << (7 - 2 * (fieldId % 4) - 1))) == 0)) {
+                        closedFields[fieldId] = AMissing.MISSING;
+                        continue;
+                    }
                     closedFields[fieldId] = (IAObject) deserializers[fieldId].deserialize(in);
                 }
             }
@@ -219,6 +224,8 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
 
     public static final int getFieldOffsetById(byte[] serRecord, int offset, int fieldId, int nullBitmapSize,
             boolean isOpen) {
+        byte nullTestCode = (byte) (1 << (7 - 2 * (fieldId % 4)));
+        byte missingTestCode = (byte) (1 << (7 - 2 * (fieldId % 4) - 1));
         if (isOpen) {
             if (serRecord[0 + offset] == ATypeTag.RECORD.serialize()) {
                 // 5 is the index of the byte that determines whether the record
@@ -227,10 +234,15 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
                     if (nullBitmapSize > 0) {
                         // 14 = tag (1) + record Size (4) + isExpanded (1) +
                         // offset of openPart (4) + number of closed fields (4)
-                        if ((serRecord[14 + offset + fieldId / 8] & (1 << (7 - (fieldId % 8)))) == 0) {
+                        int pos = 14 + offset + fieldId / 4;
+                        if ((serRecord[pos] & nullTestCode) == 0) {
                             // the field value is null
                             return 0;
                         }
+                        if ((serRecord[pos] & missingTestCode) == 0) {
+                            // the field value is missing
+                            return -1;
+                        }
                     }
                     return offset + AInt32SerializerDeserializer.getInt(serRecord,
                             14 + offset + nullBitmapSize + (4 * fieldId));
@@ -238,10 +250,15 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
                     if (nullBitmapSize > 0) {
                         // 9 = tag (1) + record Size (4) + isExpanded (1) +
                         // number of closed fields (4)
-                        if ((serRecord[10 + offset + fieldId / 8] & (1 << (7 - (fieldId % 8)))) == 0) {
+                        int pos = 10 + offset + fieldId / 4;
+                        if ((serRecord[pos] & nullTestCode) == 0) {
                             // the field value is null
                             return 0;
                         }
+                        if ((serRecord[pos] & missingTestCode) == 0) {
+                            // the field value is missing
+                            return -1;
+                        }
                     }
                     return offset + AInt32SerializerDeserializer.getInt(serRecord,
                             10 + offset + nullBitmapSize + (4 * fieldId));
@@ -250,27 +267,34 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
                 return -1;
             }
         } else {
-            if (serRecord[offset] == ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                if (nullBitmapSize > 0) {
-                    // 9 = tag (1) + record Size (4) + number of closed fields
-                    // (4)
-                    if ((serRecord[9 + offset + fieldId / 8] & (1 << (7 - (fieldId % 8)))) == 0) {
-                        // the field value is null
-                        return 0;
-                    }
+            if (serRecord[offset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
+                return Integer.MIN_VALUE;
+            }
+            if (nullBitmapSize > 0) {
+                // 9 = tag (1) + record Size (4) + number of closed fields
+                // (4)
+                int pos = 9 + offset + fieldId / 4;
+                if ((serRecord[pos] & nullTestCode) == 0) {
+                    // the field value is null
+                    return 0;
+                }
+                if ((serRecord[pos] & missingTestCode) == 0) {
+                    // the field value is missing
+                    return -1;
                 }
-                return offset
-                        + AInt32SerializerDeserializer.getInt(serRecord, 9 + offset + nullBitmapSize + (4 * fieldId));
-            } else {
-                return -1;
             }
+            return offset + AInt32SerializerDeserializer.getInt(serRecord, 9 + offset + nullBitmapSize + (4 * fieldId));
         }
     }
 
     public static final int getFieldOffsetByName(byte[] serRecord, int start, int len, byte[] fieldName, int nstart)
             throws HyracksDataException {
-        int openPartOffset = 0;
+        int openPartOffset;
         if (serRecord[start] == ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
+            if (len <= 5) {
+                // Empty record
+                return -1;
+            }
             // 5 is the index of the byte that determines whether the record is
             // expanded or not, i.e. it has an open part.
             if (serRecord[start + 5] == 1) { // true


Mime
View raw message