[NO ISSUE][FUN] DATETIME constructor should accept TIME

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Fix datetime() constructor function to handle TIME
  argument, instead of returning NULL

Change-Id: I9eab6b3e29642ef6d7f88808e7eb446e8f7c455c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/15203
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Reviewed-by: Ian Maxon <imaxon@uci.edu>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.query.sqlpp
index 97a9955..eb34dbf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_01/datetime_01.3.query.sqlpp
@@ -34,7 +34,8 @@
     '-19280329T17493737+0630',
     '-19280301T05493737+0630',
     test.datetime('-19280301T05493737+0630'),
-    date('2020-01-02')
+    date('2020-01-02'),
+    time('01:02:03.456')
 ],
 testNull = [
   null,
@@ -47,7 +48,6 @@
   int64(0),
   float(0),
   double(0),
-  time('01:02:03'),
   duration('PT0H'),
   year_month_duration('P0Y0M'),
   day_time_duration('P0D')
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_02/datetime_02.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_02/datetime_02.1.query.sqlpp
index 082d840..dec3016 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_02/datetime_02.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/constructor/datetime_02/datetime_02.1.query.sqlpp
@@ -24,8 +24,7 @@
   "null_0": datetime("@#!"),
   "null_1": datetime(false),
   "null_2": datetime(0),
-  "null_3": datetime(time("01:02:03")),
-  "null_4": datetime([]),
-  "null_5": datetime({}),
-  "null_6": datetime("1951-12-27T12:20:15Z", "INVALID_FORMAT")
+  "null_3": datetime([]),
+  "null_4": datetime({}),
+  "null_5": datetime("1951-12-27T12:20:15Z", "INVALID_FORMAT")
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_01/datetime_01.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_01/datetime_01.1.adm
index 8d2b2d2..cb20c29 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_01/datetime_01.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_01/datetime_01.1.adm
@@ -14,6 +14,7 @@
 { "g": 0, "i": 13, "actual": datetime("-1928-03-01T05:49:37.370") }
 { "g": 0, "i": 14, "actual": datetime("-1928-03-01T05:49:37.370") }
 { "g": 0, "i": 15, "actual": datetime("2020-01-02T00:00:00.000") }
+{ "g": 0, "i": 16, "actual": datetime("1970-01-01T01:02:03.456") }
 { "g": 1, "i": 0, "expected": null, "actual": null }
 { "g": 1, "i": 1, "expected": null, "actual": null }
 { "g": 1, "i": 2, "expected": null, "actual": null }
@@ -27,5 +28,4 @@
 { "g": 1, "i": 10, "expected": null, "actual": null }
 { "g": 1, "i": 11, "expected": null, "actual": null }
 { "g": 1, "i": 12, "expected": null, "actual": null }
-{ "g": 1, "i": 13, "expected": null, "actual": null }
 { "g": 2, "i": 0, "expected": true, "actual": true }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_02/datetime_02.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_02/datetime_02.1.adm
index a7601ae..4d80977 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_02/datetime_02.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/constructor/datetime_02/datetime_02.1.adm
@@ -1 +1 @@
-{ "null_0": null, "null_1": null, "null_2": null, "null_3": null, "null_4": null, "null_5": null, "null_6": null }
\ No newline at end of file
+{ "null_0": null, "null_1": null, "null_2": null, "null_3": null, "null_4": null, "null_5": null }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast
index b348fda..ad2b9d9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/datetime_01/datetime_01.3.ast
@@ -22,6 +22,9 @@
     FunctionCall asterix.date@1[
       LiteralExpr [STRING] [2020-01-02]
     ]
+    FunctionCall asterix.time@1[
+      LiteralExpr [STRING] [01:02:03.456]
+    ]
   ]
 Let Variable [ Name=$testNull ]
   :=
@@ -48,9 +51,6 @@
     FunctionCall asterix.double@1[
       LiteralExpr [LONG] [0]
     ]
-    FunctionCall asterix.time@1[
-      LiteralExpr [STRING] [01:02:03]
-    ]
     FunctionCall asterix.duration@1[
       LiteralExpr [STRING] [PT0H]
     ]
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 0b98369..bc9353b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3674,10 +3674,9 @@
         <expected-warn>ASX0006: Invalid format for datetime in @#! (in line 24, at column 13)</expected-warn>
         <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type boolean (in line 25, at column 13)</expected-warn>
         <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type bigint (in line 26, at column 13)</expected-warn>
-        <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type time (in line 27, at column 13)</expected-warn>
-        <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type array (in line 28, at column 13)</expected-warn>
-        <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type object (in line 29, at column 13)</expected-warn>
-        <expected-warn>ASX0006: Invalid format for datetime in 1951-12-27T12:20:15Z (in line 30, at column 13)</expected-warn>
+        <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type array (in line 27, at column 13)</expected-warn>
+        <expected-warn>ASX0004: Unsupported type: datetime() cannot process input type object (in line 28, at column 13)</expected-warn>
+        <expected-warn>ASX0006: Invalid format for datetime in 1951-12-27T12:20:15Z (in line 29, at column 13)</expected-warn>
       </compilation-unit>
     </test-case>
     <test-case FilePath="constructor">
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AbstractDateTimeConstructorEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AbstractDateTimeConstructorEvaluator.java
index 6765d90..3b4355d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AbstractDateTimeConstructorEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AbstractDateTimeConstructorEvaluator.java
@@ -20,6 +20,7 @@
 package org.apache.asterix.runtime.evaluators.constructors;
 
 import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
 import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.om.base.ADateTime;
 import org.apache.asterix.om.base.AMutableDateTime;
@@ -67,6 +68,13 @@
                 datetimeSerde.serialize(aDateTime, out);
                 result.set(resultStorage);
                 break;
+            case TIME:
+                int chronon = ATimeSerializerDeserializer.getChronon(bytes, startOffset + 1);
+                aDateTime.setValue(chronon);
+                resultStorage.reset();
+                datetimeSerde.serialize(aDateTime, out);
+                result.set(resultStorage);
+                break;
             case STRING:
                 utf8Ptr.set(bytes, startOffset + 1, len - 1);
                 if (parseDateTime(utf8Ptr, aDateTime)) {