asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject asterixdb git commit: Adding functions to return unit-time from date, datetime, and time.
Date Thu, 09 Jun 2016 22:53:11 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master e311a6346 -> 2176038dd


Adding functions to return unit-time from date, datetime, and time.

Change-Id: I5a71d73680d2ad47e5bb2c2d9ceec2ec0d676d09
Reviewed-on: https://asterix-gerrit.ics.uci.edu/913
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/2176038d
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/2176038d
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/2176038d

Branch: refs/heads/master
Commit: 2176038ddeeab3ae0c6f78ff2b83746373c9dcf4
Parents: e311a63
Author: Preston Carman <prestonc@apache.org>
Authored: Wed Jun 8 09:45:30 2016 -0700
Committer: Preston Carman <prestonc@apache.org>
Committed: Thu Jun 9 15:48:12 2016 -0700

----------------------------------------------------------------------
 .../translator/util/FunctionCollection.java     |   8 ++
 .../date_functions/date_functions.3.query.aql   |  21 +++-
 .../datetime_functions.3.query.aql              |  28 ++++-
 .../time_functions/time_functions.3.query.aql   |  21 +++-
 .../date_functions/date_functions.3.query.sqlpp |  23 +++-
 .../datetime_functions.3.query.sqlpp            |  24 +++-
 .../time_functions/time_functions.3.query.sqlpp |  23 +++-
 .../date_functions/date_functions.1.adm         |   2 +-
 .../datetime_functions/datetime_functions.1.adm |   2 +-
 .../time_functions/time_functions.1.adm         |   2 +-
 .../date_functions/date_functions.3.ast         |  18 ++-
 .../datetime_functions/datetime_functions.3.ast |  32 ++++++
 .../time_functions/time_functions.3.ast         |  16 +++
 .../src/site/markdown/aql/functions.md          |  62 +++++++++-
 .../om/functions/AsterixBuiltinFunctions.java   |  12 ++
 .../UnixTimeFromDateInDaysDescriptor.java       | 110 ++++++++++++++++++
 .../UnixTimeFromDatetimeInMsDescriptor.java     | 109 ++++++++++++++++++
 .../UnixTimeFromDatetimeInSecsDescriptor.java   | 113 +++++++++++++++++++
 .../UnixTimeFromTimeInMsDescriptor.java         | 110 ++++++++++++++++++
 19 files changed, 717 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
index 820d935..24ddaf6 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
@@ -274,6 +274,10 @@ import org.apache.asterix.runtime.evaluators.functions.temporal.PrintDateTimeDes
 import org.apache.asterix.runtime.evaluators.functions.temporal.PrintTimeDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.temporal.TimeFromDatetimeDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.temporal.TimeFromUnixTimeInMsDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.UnixTimeFromDateInDaysDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.UnixTimeFromDatetimeInMsDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.UnixTimeFromDatetimeInSecsDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.UnixTimeFromTimeInMsDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.temporal.YearMonthDurationGreaterThanComparatorDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.temporal.YearMonthDurationLessThanComparatorDescriptor;
 import org.apache.asterix.runtime.evaluators.staticcodegen.CodeGenUtil;
@@ -557,6 +561,10 @@ public class FunctionCollection {
         functionsToInjectUnkownHandling.add(TemporalIntervalEndDatetimeAccessor.FACTORY);
 
         // Temporal functions
+        functionsToInjectUnkownHandling.add(UnixTimeFromDateInDaysDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(UnixTimeFromTimeInMsDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(UnixTimeFromDatetimeInMsDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(UnixTimeFromDatetimeInSecsDescriptor.FACTORY);
         functionsToInjectUnkownHandling.add(DateFromUnixTimeInDaysDescriptor.FACTORY);
         functionsToInjectUnkownHandling.add(DateFromDatetimeDescriptor.FACTORY);
         functionsToInjectUnkownHandling.add(TimeFromUnixTimeInMsDescriptor.FACTORY);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
index 9a3538c..8961b65 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
@@ -21,6 +21,8 @@ set import-private-functions 'true';
 
 let $d1 := date-from-unix-time-in-days(15600)
 let $null1 := date-from-unix-time-in-days(null)
+let $unix1 := unix-time-from-date-in-days($d1)
+let $nullunix1 := date-from-unix-time-in-days(null)
 let $dt1 := datetime("1327-12-02T23:35:49.938Z")
 let $d2 := get-date-from-datetime($dt1)
 let $null2 := get-date-from-datetime(null)
@@ -39,4 +41,21 @@ let $dr4 := $d4 - $d1
 let $null5 := null - $d2
 let $null6 := $d5 - null
 
-return { "date1": $d1, "date2": $d2, "date3": $d3, "date4": $d4, "date5": $d5, "duration1": $dr3, "duration2": $dr4, "c1": $c1, "c2": $c2, "null1": $null1, "null2": $null2, "null3": $null3, "null4": $null4, "null5": $null5, "null6": $null6 }
+return {
+  "date1": $d1,
+  "date2": $d2,
+  "date3": $d3,
+  "date4": $d4,
+  "date5": $d5,
+  "unix1": $unix1,
+  "duration1": $dr3,
+  "duration2": $dr4,
+  "c1": $c1,
+  "c2": $c2,
+  "null1": $null1,
+  "nullunix1": $nullunix1,
+  "null2": $null2,
+  "null3": $null3,
+  "null4": $null4,
+  "null5": $null5,
+  "null6": $null6 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
index 2a28323..b94b5bf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
@@ -21,8 +21,12 @@ set import-private-functions 'true';
 
 let $dt1 := datetime-from-unix-time-in-ms(956007429)
 let $null1 := datetime-from-unix-time-in-ms(null)
-let $dtsecs := datetime-from-unix-time-in-secs(1356048000)
-let $nullsecs := datetime-from-unix-time-in-secs(null)
+let $dtsecs1 := datetime-from-unix-time-in-secs(1356048000)
+let $nullsecs1 := datetime-from-unix-time-in-secs(null)
+let $unixms1 := unix-time-from-datetime-in-ms($dt1)
+let $nullunixms1 := unix-time-from-datetime-in-ms(null)
+let $unixsecs1 := unix-time-from-datetime-in-secs($dtsecs1)
+let $nullunixsecs1 := unix-time-from-datetime-in-secs(null)
 let $d1 := date("1327-12-02")
 let $t1 := time("15:35:49.938-0800")
 let $dt2 := datetime-from-date-time($d1, $t1)
@@ -36,4 +40,22 @@ let $null6 := null + $dr1
 let $null7 := $dt1 + null
 let $c1 := $dt1 = ($dt1 - $dt3) + $dt3
 
-return { "datetime1" : $dt1, "datetime1secs": $dtsecs, "datetime2" : $dt2, "datetime3" : $dt3, "duration1" : $dr1, "c1" : $c1, "null1" : $null1, "null1secs": $nullsecs, "null2" : $null2, "null3" : $null3, "null4" : $null4, "null5" : $null5, "null6" : $null6, "null7" : $null7 }
+return {
+  "datetime1" : $dt1,
+  "datetime1secs": $dtsecs1,
+  "datetime2" : $dt2,
+  "datetime3" : $dt3,
+  "unixms1" : $unixms1,
+  "unixsecs1": $unixsecs1,
+  "duration1" : $dr1,
+  "c1" : $c1,
+  "null1" : $null1,
+  "null1secs": $nullsecs1,
+  "nullunixms1" : $nullunixms1,
+  "nullunixsecs1": $nullunixsecs1,
+  "null2" : $null2,
+  "null3" : $null3,
+  "null4" : $null4,
+  "null5" : $null5,
+  "null6" : $null6,
+  "null7" : $null7 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
index 5ecbbfd..ae6698d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
@@ -21,6 +21,8 @@ set import-private-functions 'true';
 
 let $t1 := time-from-unix-time-in-ms(1560074)
 let $null1 := time-from-unix-time-in-ms(null)
+let $unix1 := unix-time-from-time-in-ms($t1)
+let $nullunix1 := unix-time-from-time-in-ms(null)
 let $dt1 := datetime("1327-12-02T23:35:49.938Z")
 let $t2 := get-time-from-datetime($dt1)
 let $null2 := get-time-from-datetime(null)
@@ -42,4 +44,21 @@ let $ct := current-time()
 let $cd := current-date()
 let $cdt := current-datetime()
 
-return { "time1" : $t1, "time2" : $t2, "time3" : $t3, "time4" : $t4, "time5" : $t5, "duration1" : $dr3, "duration2" : $dr4, "c1" : $c1, "c2" : $c2, "null1": $null1, "null2": $null2, "null3": $null3, "null4": $null4, "null5": $null5, "null6": $null6 }
+return {
+  "time1" : $t1,
+  "time2" : $t2,
+  "time3" : $t3,
+  "time4" : $t4,
+  "time5" : $t5,
+  "unix1" : $unix1,
+  "duration1" : $dr3,
+  "duration2" : $dr4,
+  "c1" : $c1,
+  "c2" : $c2,
+  "null1": $null1,
+  "nullunix1": $nullunix1,
+  "null2": $null2,
+  "null3": $null3,
+  "null4": $null4,
+  "null5": $null5,
+  "null6": $null6 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp
index 660457d..cd03a90 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/date_functions/date_functions.3.query.sqlpp
@@ -4,14 +4,14 @@
  * 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
+ * '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
+ * '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.
@@ -22,4 +22,21 @@ use test;
 
 set `import-private-functions` `true`;
 
-{'date1':test.`date-from-unix-time-in-days`(15600),'date2':test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')),'date3':test.`get-date-from-datetime`(test.datetime('2012-10-11T02:30:23+03:00')),'date4':(test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H')),'date5':(test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')),'duration1':((test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) - test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z'))),'duration2':((test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H')) - test.`date-from-unix-time-in-days`(15600)),'c1':(test.`date-from-unix-time-in-days`(15600) = ((test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H')) + (test.`date-from-unix-time-in-days`(15600) - (test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M9
 0DT30H'))))),'c2':(test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) = ((test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) + (test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) - (test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M'))))),'null1':test.`date-from-unix-time-in-days`(null),'null2':test.`get-date-from-datetime`(null),'null3':(null + test.duration('-P2Y1M90DT30H')),'null4':(test.`date-from-unix-time-in-days`(15600) + null),'null5':(null - test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z'))),'null6':((test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) - null)};
+{ 'date1' : test.`date-from-unix-time-in-days`(15600)
+, 'date2' : test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z'))
+, 'date3' : test.`get-date-from-datetime`(test.datetime('2012-10-11T02:30:23+03:00'))
+, 'date4' : (test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H'))
+, 'date5' : (test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M'))
+, 'unix1' : test.`unix-time-from-date-in-days`(test.`date-from-unix-time-in-days`(15600))
+, 'duration1' : ((test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) - test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')))
+, 'duration2' : ((test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H')) - test.`date-from-unix-time-in-days`(15600))
+, 'c1' : (test.`date-from-unix-time-in-days`(15600) = ((test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H')) + (test.`date-from-unix-time-in-days`(15600) - (test.`date-from-unix-time-in-days`(15600) + test.duration('-P2Y1M90DT30H')))))
+, 'c2' : (test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) = ((test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) + (test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) - (test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')))))
+, 'null1' : test.`date-from-unix-time-in-days`(null)
+, 'nullunix1' : test.`unix-time-from-date-in-days`(null)
+, 'null2' : test.`get-date-from-datetime`(null)
+, 'null3' : (null + test.duration('-P2Y1M90DT30H'))
+, 'null4' : (test.`date-from-unix-time-in-days`(15600) + null)
+, 'null5' : (null - test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')))
+, 'null6' : ((test.`get-date-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.duration('P300Y900MT360000M')) - null)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp
index 65c6bdf..e28661a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/datetime_functions/datetime_functions.3.query.sqlpp
@@ -4,14 +4,14 @@
  * 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
+ * '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
+ * '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.
@@ -22,4 +22,22 @@ use test;
 
 set `import-private-functions` `true`;
 
-{'datetime1':test.`datetime-from-unix-time-in-ms`(956007429),'datetime1secs':test.`datetime-from-unix-time-in-secs`(1356048000),'datetime2':test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')),'datetime3':(test.`datetime-from-unix-time-in-ms`(956007429) + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429))),'duration1':(test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429)),'c1':(test.`datetime-from-unix-time-in-ms`(956007429) = ((test.`datetime-from-unix-time-in-ms`(956007429) - (test.`datetime-from-unix-time-in-ms`(956007429) + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429)))) + (test.`datetime-from-unix-time-in-ms`(956007429) + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.ti
 me('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429))))),'null1':test.`datetime-from-unix-time-in-ms`(null),'null1secs':test.`datetime-from-unix-time-in-secs`(null),'null2':test.`datetime-from-date-time`(null,test.time('15:35:49.938-0800')),'null3':test.`datetime-from-date-time`(test.date('1327-12-02'),null),'null4':(null - test.`datetime-from-unix-time-in-ms`(956007429)),'null5':(test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - null),'null6':(null + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429))),'null7':(test.`datetime-from-unix-time-in-ms`(956007429) + null)};
+{ 'datetime1' : test.`datetime-from-unix-time-in-ms`(956007429)
+, 'datetime1secs' : test.`datetime-from-unix-time-in-secs`(1356048000)
+, 'datetime2' : test.`datetime-from-date-time`(test.date('1327-12-02'), test.time('15:35:49.938-0800'))
+, 'datetime3' : (test.`datetime-from-unix-time-in-ms`(956007429) + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429)))
+, 'unixms1' : test.`unix-time-from-datetime-in-ms`(test.`datetime-from-unix-time-in-ms`(956007429))
+, 'unixsecs1' : test.`unix-time-from-datetime-in-secs`(test.`datetime-from-unix-time-in-secs`(1356048000))
+, 'duration1' : (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429))
+, 'c1' : (test.`datetime-from-unix-time-in-ms`(956007429) = ((test.`datetime-from-unix-time-in-ms`(956007429) - (test.`datetime-from-unix-time-in-ms`(956007429) + (test.`datetime-from-date-time`(test.date('1327-12-02'), test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429)))) + (test.`datetime-from-unix-time-in-ms`(956007429) + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429)))))
+, 'null1' : test.`datetime-from-unix-time-in-ms`(null)
+, 'null1secs' : test.`datetime-from-unix-time-in-secs`(null)
+, 'nullunixms1' : test.`unix-time-from-datetime-in-ms`(null)
+, 'nullunixsecs1' : test.`unix-time-from-datetime-in-secs`(null)
+, 'null2' : test.`datetime-from-date-time`(null,test.time('15:35:49.938-0800'))
+, 'null3' : test.`datetime-from-date-time`(test.date('1327-12-02'),null)
+, 'null4' : (null - test.`datetime-from-unix-time-in-ms`(956007429))
+, 'null5' : (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - null)
+, 'null6' : (null + (test.`datetime-from-date-time`(test.date('1327-12-02'),test.time('15:35:49.938-0800')) - test.`datetime-from-unix-time-in-ms`(956007429)))
+, 'null7' : (test.`datetime-from-unix-time-in-ms`(956007429) + null)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp
index 5a78aa2..c24a431 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/temporal/time_functions/time_functions.3.query.sqlpp
@@ -4,14 +4,14 @@
  * 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
+ * '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
+ * '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.
@@ -22,4 +22,21 @@ use test;
 
 set `import-private-functions` `true`;
 
-{'time1':test.`time-from-unix-time-in-ms`(1560074),'time2':test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')),'time3':test.`get-time-from-datetime`(test.datetime('2012-10-11T02:30:23+03:00')),'time4':(test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H')),'time5':(test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M')),'duration1':((test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M')) - test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z'))),'duration2':((test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H')) - test.`time-from-unix-time-in-ms`(1560074)),'c1':(test.`time-from-unix-time-in-ms`(1560074) = ((test.`time-from-unix-time-in-ms`(1560074) - (test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H'))) + (test.`time-from-unix-time-in-ms`(1560074) + test.`day-t
 ime-duration`('-PT30H')))),'c2':(test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) = ((test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M')) + (test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) - (test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M'))))),'null1':test.`time-from-unix-time-in-ms`(null),'null2':test.`get-time-from-datetime`(null),'null3':(null + test.`day-time-duration`('-PT30H')),'null4':(test.`time-from-unix-time-in-ms`(1560074) + null),'null5':(null - test.`time-from-unix-time-in-ms`(1560074)),'null6':((test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H')) - null)};
+{ 'time1' : test.`time-from-unix-time-in-ms`(1560074)
+, 'time2' : test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z'))
+, 'time3' : test.`get-time-from-datetime`(test.datetime('2012-10-11T02:30:23+03:00'))
+, 'time4' : (test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H'))
+, 'time5' : (test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M'))
+, 'unix1' : test.`unix-time-from-time-in-ms`(test.`time-from-unix-time-in-ms`(1560074))
+, 'duration1' : ((test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M')) - test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')))
+, 'duration2' : ((test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H')) - test.`time-from-unix-time-in-ms`(1560074))
+, 'c1' : (test.`time-from-unix-time-in-ms`(1560074) = ((test.`time-from-unix-time-in-ms`(1560074) - (test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H'))) + (test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H'))))
+, 'c2' : (test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) = ((test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M')) + (test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) - (test.`get-time-from-datetime`(test.datetime('1327-12-02T23:35:49.938Z')) + test.`day-time-duration`('PT36M')))))
+, 'null1' : test.`time-from-unix-time-in-ms`(null)
+, 'nullunix1' : test.`unix-time-from-time-in-ms`(null)
+, 'null2' : test.`get-time-from-datetime`(null)
+, 'null3' : (null + test.`day-time-duration`('-PT30H'))
+, 'null4' : (test.`time-from-unix-time-in-ms`(1560074) + null)
+, 'null5' : (null - test.`time-from-unix-time-in-ms`(1560074))
+, 'null6' : ((test.`time-from-unix-time-in-ms`(1560074) + test.`day-time-duration`('-PT30H')) - null)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
index e58d009..5529bfd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
@@ -1 +1 @@
-{ "date1": date("2012-09-17"), "date2": date("1327-12-02"), "date3": date("2012-10-10"), "date4": date("2010-05-17"), "date5": date("1703-08-09"), "duration1": duration("P137216D"), "duration2": duration("-P854D"), "c1": true, "c2": true, "null1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null }
+{ "date1": date("2012-09-17"), "date2": date("1327-12-02"), "date3": date("2012-10-10"), "date4": date("2010-05-17"), "date5": date("1703-08-09"), "unix1": 15600, "duration1": duration("P137216D"), "duration2": duration("-P854D"), "c1": true, "c2": true, "null1": null, "nullunix1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
index f52ba70..6107bc2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
@@ -1 +1 @@
-{ "datetime1": datetime("1970-01-12T01:33:27.429Z"), "datetime1secs": datetime("2012-12-21T00:00:00.000Z"), "datetime2": datetime("1327-12-02T23:35:49.938Z"), "datetime3": datetime("1327-12-02T23:35:49.938Z"), "duration1": duration("-P234526DT1H57M37.491S"), "c1": true, "null1": null, "null1secs": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null, "null7": null }
+{ "datetime1": datetime("1970-01-12T01:33:27.429Z"), "datetime1secs": datetime("2012-12-21T00:00:00.000Z"), "datetime2": datetime("1327-12-02T23:35:49.938Z"), "datetime3": datetime("1327-12-02T23:35:49.938Z"), "unixms1": 956007429, "unixsecs1": 1356048000, "duration1": duration("-P234526DT1H57M37.491S"), "c1": true, "null1": null, "null1secs": null, "nullunixms1": null, "nullunixsecs1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null, "null7": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
index a144cee..303e762 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
@@ -1 +1 @@
-{ "time1": time("00:26:00.074Z"), "time2": time("23:35:49.938Z"), "time3": time("23:30:23.000Z"), "time4": time("18:26:00.074Z"), "time5": time("00:11:49.938Z"), "duration1": duration("-PT23H24M"), "duration2": duration("PT18H"), "c1": true, "c2": true, "null1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null }
+{ "time1": time("00:26:00.074Z"), "time2": time("23:35:49.938Z"), "time3": time("23:30:23.000Z"), "time4": time("18:26:00.074Z"), "time5": time("00:11:49.938Z"), "unix1": 1560074, "duration1": duration("-PT23H24M"), "duration2": duration("PT18H"), "c1": true, "c2": true, "null1": null, "nullunix1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast
index e5dfd2f..9110e70 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/date_functions/date_functions.3.ast
@@ -56,6 +56,15 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [unix1]
+    :
+    FunctionCall test.unix-time-from-date-in-days@1[
+      FunctionCall test.date-from-unix-time-in-days@1[
+        LiteralExpr [LONG] [15600]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [duration1]
     :
     OperatorExpr [
@@ -187,6 +196,13 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [nullunix1]
+    :
+    FunctionCall test.unix-time-from-date-in-days@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
     LiteralExpr [STRING] [null2]
     :
     FunctionCall test.get-date-from-datetime@1[
@@ -247,4 +263,4 @@ RecordConstructor [
       LiteralExpr [NULL]
     ]
   )
-]
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast
index ca6836e..1a36e5a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/datetime_functions/datetime_functions.3.ast
@@ -53,6 +53,24 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [unixms1]
+    :
+    FunctionCall test.unix-time-from-datetime-in-ms@1[
+      FunctionCall test.datetime-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [956007429]
+      ]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [unixsecs1]
+    :
+    FunctionCall test.unix-time-from-datetime-in-secs@1[
+      FunctionCall test.datetime-from-unix-time-in-secs@1[
+        LiteralExpr [LONG] [1356048000]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [duration1]
     :
     OperatorExpr [
@@ -144,6 +162,20 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [nullunixms1]
+    :
+    FunctionCall test.unix-time-from-datetime-in-ms@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
+    LiteralExpr [STRING] [nullunixsecs1]
+    :
+    FunctionCall test.unix-time-from-datetime-in-secs@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
     LiteralExpr [STRING] [null2]
     :
     FunctionCall test.datetime-from-date-time@2[

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast
index 3b8a3c8..2baf9252d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/temporal/time_functions/time_functions.3.ast
@@ -56,6 +56,15 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [unix1]
+    :
+    FunctionCall test.unix-time-from-time-in-ms@1[
+      FunctionCall test.time-from-unix-time-in-ms@1[
+        LiteralExpr [LONG] [1560074]
+      ]
+    ]
+  )
+  (
     LiteralExpr [STRING] [duration1]
     :
     OperatorExpr [
@@ -187,6 +196,13 @@ RecordConstructor [
     ]
   )
   (
+    LiteralExpr [STRING] [nullunix1]
+    :
+    FunctionCall test.unix-time-from-time-in-ms@1[
+      LiteralExpr [NULL]
+    ]
+  )
+  (
     LiteralExpr [STRING] [null2]
     :
     FunctionCall test.get-time-from-datetime@1[

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-doc/src/site/markdown/aql/functions.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/site/markdown/aql/functions.md b/asterixdb/asterix-doc/src/site/markdown/aql/functions.md
index 8593ad0..3b78a93 100644
--- a/asterixdb/asterix-doc/src/site/markdown/aql/functions.md
+++ b/asterixdb/asterix-doc/src/site/markdown/aql/functions.md
@@ -1791,7 +1791,7 @@ including [edit distance](http://en.wikipedia.org/wiki/Levenshtein_distance) and
 
  * Get the time value from the given datetime value `datetime`
  * Arguments:
-    * `datetime`: A `datetime` value to be extracted from
+    * `datetime`: A `datetime` value to be extracted from.
  * Return Value:
     * A `time` value from the datetime.
 
@@ -1905,6 +1905,66 @@ datetime-from-date-time(date,time)
         { "date": date("2013-04-05"), "datetime": datetime("2013-04-05T05:28:20.000Z"), "time": time("00:00:03.748Z") }
 
 
+### unix-time-from-date-in-days ###
+ * Syntax:
+
+        unix-time-from-date-in-days(date_value)
+
+ * Gets an integer value representing the number of days since 1970-01-01 for `date_value`.
+ * Arguments:
+    * `date_value`: A `date` value.
+ * Return Value:
+    * A `int64` value representing the number of days.
+
+### unix-time-from-datetime-in-ms ###
+ * Syntax:
+
+        unix-time-from-datetime-in-ms(datetime_value)
+
+ * Gets an integer value representing the time in milliseconds since 1970-01-01T00:00:00Z for `datetime_value`.
+ * Arguments:
+    * `datetime_value` : A `datetime` value.
+ * Return Value:
+    * A `int64` value representing the number of milliseconds.
+
+### unix-time-from-datetime-in-secs ###
+ * Syntax:
+
+        unix-time-from-datetime-in-secs(datetime_value)
+
+ * Gets an integer value representing the time in seconds since 1970-01-01T00:00:00Z for `datetime_value`.
+ * Arguments:
+    * `datetime_value` : A `datetime` value.
+ * Return Value:
+    * A `int64` value representing the number of seconds.
+
+
+### unix-time-from-time-in-ms ###
+ * Syntax:
+
+        unix-time-from-time-in-ms(time_value)
+
+ * Gets an integer value representing the time the milliseconds since 00:00:00.000Z for `time_value`.
+ * Arguments:
+    * `time_value` : A `time` value.
+ * Return Value:
+    * A `int64` value representing the number of milliseconds.
+
+ * Example:
+
+        use dataverse TinySocial;
+
+        let $d := date-from-unix-time-in-days(15800)
+        let $dt := datetime-from-unix-time-in-ms(1365139700000)
+        let $t := time-from-unix-time-in-ms(3748)
+        return {"date": $d, "datetime": $dt, "time": $t}
+
+
+ * The expected result is:
+
+        { "date": date("2013-04-05"), "datetime": datetime("2013-04-05T05:28:20.000Z"), "time": time("00:00:03.748Z") }
+
+
 ### parse-date/parse-time/parse-datetime ###
 * Syntax:
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
index fafbb4d..afed6c9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -637,6 +637,14 @@ public class AsterixBuiltinFunctions {
             FunctionConstants.ASTERIX_NS, "get-overlapping-interval", 2);
 
     // Temporal functions
+    public static final FunctionIdentifier UNIX_TIME_FROM_DATE_IN_DAYS = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "unix-time-from-date-in-days", 1);
+    public final static FunctionIdentifier UNIX_TIME_FROM_TIME_IN_MS = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "unix-time-from-time-in-ms", 1);
+    public final static FunctionIdentifier UNIX_TIME_FROM_DATETIME_IN_MS = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "unix-time-from-datetime-in-ms", 1);
+    public final static FunctionIdentifier UNIX_TIME_FROM_DATETIME_IN_SECS = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "unix-time-from-datetime-in-secs", 1);
     public static final FunctionIdentifier DATE_FROM_UNIX_TIME_IN_DAYS = new FunctionIdentifier(
             FunctionConstants.ASTERIX_NS, "date-from-unix-time-in-days", 1);
     public static final FunctionIdentifier DATE_FROM_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
@@ -973,6 +981,10 @@ public class AsterixBuiltinFunctions {
         addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_TIME, ATimeTypeComputer.INSTANCE, true);
 
         // temporal functions
+        addFunction(UNIX_TIME_FROM_DATE_IN_DAYS, AInt64TypeComputer.INSTANCE, true);
+        addFunction(UNIX_TIME_FROM_TIME_IN_MS, AInt64TypeComputer.INSTANCE, true);
+        addFunction(UNIX_TIME_FROM_DATETIME_IN_MS, AInt64TypeComputer.INSTANCE, true);
+        addFunction(UNIX_TIME_FROM_DATETIME_IN_SECS, AInt64TypeComputer.INSTANCE, true);
         addFunction(DATE_FROM_UNIX_TIME_IN_DAYS, ADateTypeComputer.INSTANCE, true);
         addFunction(DATE_FROM_DATETIME, ADateTypeComputer.INSTANCE, true);
         addFunction(TIME_FROM_UNIX_TIME_IN_MS, ATimeTypeComputer.INSTANCE, true);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDateInDaysDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDateInDaysDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDateInDaysDescriptor.java
new file mode 100644
index 0000000..7268302
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDateInDaysDescriptor.java
@@ -0,0 +1,110 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AInt64;
+import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class UnixTimeFromDateInDaysDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new UnixTimeFromDateInDaysDescriptor();
+        }
+    };
+
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr = new VoidPointable();
+                    private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+
+                    // possible returning types
+                    private AMutableInt64 aInt64 = new AMutableInt64(0);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AINT64);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int offset = argPtr.getStartOffset();
+
+                        try {
+                            if (bytes[offset] != ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": expects input type DATE/NULL but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
+                            }
+                            long dateChronon = ADateSerializerDeserializer.getChronon(bytes, offset + 1);
+                            aInt64.setValue(dateChronon);
+                            int64Serde.serialize(aInt64, out);
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                        result.set(resultStorage);
+                    }
+                };
+            }
+        };
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.UNIX_TIME_FROM_DATE_IN_DAYS;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInMsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInMsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInMsDescriptor.java
new file mode 100644
index 0000000..fe76f32
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInMsDescriptor.java
@@ -0,0 +1,109 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AInt64;
+import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class UnixTimeFromDatetimeInMsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new UnixTimeFromDatetimeInMsDescriptor();
+        }
+    };
+
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr = new VoidPointable();
+                    private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+
+                    // possible returning types
+                    private AMutableInt64 aInt64 = new AMutableInt64(0);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AINT64);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int offset = argPtr.getStartOffset();
+
+                        try {
+                            if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": expects input type DATETIME/NULL but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
+                            }
+                            long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
+                            aInt64.setValue(datetimeChronon);
+                            int64Serde.serialize(aInt64, out);
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                        result.set(resultStorage);
+                    }
+                };
+            }
+        };
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.UNIX_TIME_FROM_DATETIME_IN_MS;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInSecsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInSecsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInSecsDescriptor.java
new file mode 100644
index 0000000..162f002
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromDatetimeInSecsDescriptor.java
@@ -0,0 +1,113 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AInt64;
+import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class UnixTimeFromDatetimeInSecsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new UnixTimeFromDatetimeInSecsDescriptor();
+        }
+    };
+
+    /* (non-Javadoc)
+     * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
+     */
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr = new VoidPointable();
+                    private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+
+                    // possible returning types
+                    private AMutableInt64 aInt64 = new AMutableInt64(0);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AINT64);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int offset = argPtr.getStartOffset();
+
+                        try {
+                            if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": expects input type DATETIME/NULL but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
+                            }
+                            long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
+                            aInt64.setValue(datetimeChronon / 1000L);
+                            int64Serde.serialize(aInt64, out);
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                        result.set(resultStorage);
+                    }
+                };
+            }
+        };
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.UNIX_TIME_FROM_DATETIME_IN_SECS;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2176038d/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromTimeInMsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromTimeInMsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromTimeInMsDescriptor.java
new file mode 100644
index 0000000..1beb772
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/UnixTimeFromTimeInMsDescriptor.java
@@ -0,0 +1,110 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AInt64;
+import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class UnixTimeFromTimeInMsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new UnixTimeFromTimeInMsDescriptor();
+        }
+    };
+
+    /* (non-Javadoc)
+     * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
+     */
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr = new VoidPointable();
+                    private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+
+                    // possible returning types
+                    private AMutableInt64 aInt64 = new AMutableInt64(0);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AINT64);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int offset = argPtr.getStartOffset();
+
+                        try {
+                            if (bytes[offset] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": expects input type TIME/NULL but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
+                            }
+                            long timeChronon = ATimeSerializerDeserializer.getChronon(bytes, offset + 1);
+                            aInt64.setValue(timeChronon);
+                            int64Serde.serialize(aInt64, out);
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                        result.set(resultStorage);
+                    }
+                };
+            }
+        };
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.UNIX_TIME_FROM_TIME_IN_MS;
+    }
+}


Mime
View raw message