asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [2/2] asterixdb git commit: Add several unary numeric builtin functions.
Date Fri, 19 Aug 2016 01:11:21 GMT
Add several unary numeric builtin functions.

- newly added functions include: acos, asin, atan, cos, exp, ln,
  log, sign, sin, sqrt and tan;
- refactor and simplify numeric function implementations.

Change-Id: Ic7f945450f3cf8da543b2d68c29ef6eb0f4699d7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1086
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
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/7cb2f9ae
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/7cb2f9ae
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/7cb2f9ae

Branch: refs/heads/master
Commit: 7cb2f9aefe324cdc9ba20fef3c5bfe941ff70be0
Parents: c1ff430
Author: Yingyi Bu <yingyi@couchbase.com>
Authored: Thu Aug 18 08:02:02 2016 -0700
Committer: Yingyi Bu <buyingyi@gmail.com>
Committed: Thu Aug 18 18:10:50 2016 -0700

----------------------------------------------------------------------
 .../translator/util/FunctionCollection.java     |  22 ++
 .../results_parser_sqlpp/columnalias.ast        |   4 +-
 .../results_parser_sqlpp/columnalias2.ast       |   2 +-
 .../results_parser_sqlpp/columnalias3.ast       |   4 +-
 .../numeric/acos/acos.1.query.sqlpp             |  29 +++
 .../numeric/asin/asin.1.query.sqlpp             |  29 +++
 .../numeric/atan/atan.1.query.sqlpp             |  29 +++
 .../queries_sqlpp/numeric/cos/cos.1.query.sqlpp |  29 +++
 .../queries_sqlpp/numeric/exp/exp.1.query.sqlpp |  29 +++
 .../queries_sqlpp/numeric/ln/ln.1.query.sqlpp   |  30 +++
 .../queries_sqlpp/numeric/log/log.1.query.sqlpp |  29 +++
 .../numeric/sign/sign.1.query.sqlpp             |  30 +++
 .../queries_sqlpp/numeric/sin/sin.1.query.sqlpp |  29 +++
 .../numeric/sqrt/sqrt.1.query.sqlpp             |  30 +++
 .../queries_sqlpp/numeric/tan/tan.1.query.sqlpp |  29 +++
 .../runtimets/results/numeric/acos/acos.1.adm   |   1 +
 .../runtimets/results/numeric/asin/asin.1.adm   |   1 +
 .../runtimets/results/numeric/atan/atan.1.adm   |   1 +
 .../runtimets/results/numeric/cos/cos.1.adm     |   1 +
 .../runtimets/results/numeric/exp/exp.1.adm     |   1 +
 .../runtimets/results/numeric/ln/ln.1.adm       |   1 +
 .../runtimets/results/numeric/log/log.1.adm     |   1 +
 .../runtimets/results/numeric/sign/sign.1.adm   |   1 +
 .../runtimets/results/numeric/sin/sin.1.adm     |   1 +
 .../runtimets/results/numeric/sqrt/sqrt.1.adm   |   1 +
 .../runtimets/results/numeric/tan/tan.1.adm     |   1 +
 .../resources/runtimets/testsuite_sqlpp.xml     |  55 +++++
 .../om/functions/AsterixBuiltinFunctions.java   |  28 +++
 .../AbstractUnaryNumericDoubleFunctionEval.java |  65 ++++++
 .../AbstractUnaryNumericFunctionEval.java       | 211 +++++++++++++++++++
 .../functions/NumericACosDescriptor.java        |  72 +++++++
 .../functions/NumericASinDescriptor.java        |  73 +++++++
 .../functions/NumericATanDescriptor.java        |  73 +++++++
 .../functions/NumericAbsDescriptor.java         | 163 ++++++--------
 .../functions/NumericCeilingDescriptor.java     | 142 ++++---------
 .../functions/NumericCosDescriptor.java         |  73 +++++++
 .../functions/NumericExpDescriptor.java         |  73 +++++++
 .../functions/NumericFloorDescriptor.java       | 137 ++++--------
 .../functions/NumericLnDescriptor.java          |  73 +++++++
 .../functions/NumericLogDescriptor.java         |  73 +++++++
 .../functions/NumericSignDescriptor.java        | 103 +++++++++
 .../functions/NumericSinDescriptor.java         |  74 +++++++
 .../functions/NumericSqrtDescriptor.java        |  73 +++++++
 .../functions/NumericTanDescriptor.java         |  73 +++++++
 .../functions/NumericUnaryMinusDescriptor.java  | 144 +++++--------
 45 files changed, 1751 insertions(+), 392 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/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 3201d9e..ee4dc32 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
@@ -163,18 +163,29 @@ import org.apache.asterix.runtime.evaluators.functions.IsSystemNullDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.IsUnknownDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.LenDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NotDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericACosDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericASinDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericATanDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericAbsDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericAddDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericCaretDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericCeilingDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericCosDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericDivideDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericExpDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericFloorDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericLnDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericLogDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericModuloDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericMultiplyDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericRoundDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericRoundHalfToEven2Descriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericRoundHalfToEvenDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericSignDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericSinDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericSqrtDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericSubDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.NumericTanDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericUnaryMinusDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.OrDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.OrderedListConstructorDescriptor;
@@ -428,6 +439,17 @@ public class FunctionCollection {
         functionsToInjectUnkownHandling.add(NumericRoundDescriptor.FACTORY);
         functionsToInjectUnkownHandling.add(NumericRoundHalfToEvenDescriptor.FACTORY);
         functionsToInjectUnkownHandling.add(NumericRoundHalfToEven2Descriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericACosDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericASinDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericATanDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericCosDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericSinDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericTanDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericExpDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericLnDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericLogDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericSqrtDescriptor.FACTORY);
+        functionsToInjectUnkownHandling.add(NumericSignDescriptor.FACTORY);
 
         // Comparisons.
         functionsToInjectUnkownHandling.add(EqualsDescriptor.FACTORY);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
index 78d6362..0fdf31a 100644
--- a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
+++ b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
@@ -1,6 +1,6 @@
 Query:
 SELECT [
-FunctionCall null.SQRT@1[
+FunctionCall null.sqrt@1[
   OperatorExpr [
     FieldAccessor [
       Variable [ Name=$t ]
@@ -23,7 +23,7 @@ FROM [  FunctionCall Metadata.dataset@1[
 Groupby
   Variable [ Name=$root ]
   :=
-  FunctionCall null.SQRT@1[
+  FunctionCall null.sqrt@1[
     OperatorExpr [
       FieldAccessor [
         Variable [ Name=$t ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
index 89e3b4b..3177516 100644
--- a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
+++ b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
@@ -1,6 +1,6 @@
 Query:
 SELECT [
-FunctionCall null.SQRT@1[
+FunctionCall null.sqrt@1[
   OperatorExpr [
     FunctionCall Metadata.dataset@1[
       LiteralExpr [STRING] [t.a]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
index 056fe36..9bf4094 100644
--- a/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
+++ b/asterixdb/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
@@ -4,7 +4,7 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [root]
     :
-    FunctionCall null.SQRT@1[
+    FunctionCall null.sqrt@1[
       OperatorExpr [
         FieldAccessor [
           Variable [ Name=$t ]
@@ -28,7 +28,7 @@ FROM [  FunctionCall Metadata.dataset@1[
 Groupby
   Variable [ Name=$root ]
   :=
-  FunctionCall null.SQRT@1[
+  FunctionCall null.sqrt@1[
     OperatorExpr [
       FieldAccessor [
         Variable [ Name=$t ]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/acos/acos.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/acos/acos.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/acos/acos.1.query.sqlpp
new file mode 100644
index 0000000..c9ae50c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/acos/acos.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": acos(10.0),
+  "b": acos(0.5f),
+  "c": acos(100),
+  "d": acos(int32("0")),
+  "e": acos(int8("-1")),
+  "f": acos(int16("1")),
+  "g": acos(null),
+  "h": acos(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/asin/asin.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/asin/asin.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/asin/asin.1.query.sqlpp
new file mode 100644
index 0000000..4807859
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/asin/asin.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": asin(10.0),
+  "b": asin(0.5f),
+  "c": asin(100),
+  "d": asin(int32("0")),
+  "e": asin(int8("-1")),
+  "f": asin(int16("1")),
+  "g": asin(null),
+  "h": asin(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/atan/atan.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/atan/atan.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/atan/atan.1.query.sqlpp
new file mode 100644
index 0000000..1ca0e6e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/atan/atan.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": atan(10.0),
+  "b": atan(0.5f),
+  "c": atan(100),
+  "d": atan(int32("0")),
+  "e": atan(int8("-1")),
+  "f": atan(int16("1")),
+  "g": atan(null),
+  "h": atan(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/cos/cos.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/cos/cos.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/cos/cos.1.query.sqlpp
new file mode 100644
index 0000000..78940b2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/cos/cos.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": cos(120.0),
+  "b": cos(90.5f),
+  "c": cos(int32("90")),
+  "d": cos(int16("0")),
+  "e": cos(int8("-45")),
+  "f": cos(1),
+  "g": cos(null),
+  "h": cos(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/exp/exp.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/exp/exp.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/exp/exp.1.query.sqlpp
new file mode 100644
index 0000000..b3f0354
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/exp/exp.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": exp(120.0),
+  "b": exp(90.5f),
+  "c": exp(int32("90")),
+  "d": exp(int16("0")),
+  "e": exp(int8("-45")),
+  "f": exp(1),
+  "g": exp(null),
+  "h": exp(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ln/ln.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ln/ln.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ln/ln.1.query.sqlpp
new file mode 100644
index 0000000..ac0b71e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/ln/ln.1.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+
+{
+  "a": ln(120.0),
+  "b": ln(90.5f),
+  "c": ln(int32("90")),
+  "d": ln(int16("0")),
+  "e": ln(int8("-45")),
+  "f": ln(1),
+  "g": ln(null),
+  "h": ln(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/log/log.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/log/log.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/log/log.1.query.sqlpp
new file mode 100644
index 0000000..c9fc2f4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/log/log.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": log(120.0),
+  "b": log(90.5f),
+  "c": log(int32("90")),
+  "d": log(int16("0")),
+  "e": log(int8("-45")),
+  "f": log(1),
+  "g": log(null),
+  "h": log(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sign/sign.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sign/sign.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sign/sign.1.query.sqlpp
new file mode 100644
index 0000000..a73cc55
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sign/sign.1.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+{
+  "a": sign(120.0),
+  "b": sign(-90.5f),
+  "c": sign(int32("90")),
+  "d": sign(int16("0")),
+  "e": sign(int8("-45")),
+  "f": sign(1),
+  "g": sign(null),
+  "h": sign(missing)
+};
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sin/sin.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sin/sin.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sin/sin.1.query.sqlpp
new file mode 100644
index 0000000..c847b01
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sin/sin.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": sin(120.0),
+  "b": sin(90.5f),
+  "c": sin(int32("90")),
+  "d": sin(int16("0")),
+  "e": sin(int8("-45")),
+  "f": sin(1),
+  "g": sin(null),
+  "h": sin(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sqrt/sqrt.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sqrt/sqrt.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sqrt/sqrt.1.query.sqlpp
new file mode 100644
index 0000000..09b6160
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/sqrt/sqrt.1.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+{
+  "a": sqrt(120.0),
+  "b": sqrt(90.5f),
+  "c": sqrt(int32("90")),
+  "d": sqrt(int16("0")),
+  "e": sqrt(int8("-45")),
+  "f": sqrt(1),
+  "g": sqrt(null),
+  "h": sqrt(missing)
+};
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/tan/tan.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/tan/tan.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/tan/tan.1.query.sqlpp
new file mode 100644
index 0000000..3cfa8b6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/tan/tan.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+  "a": tan(120.0),
+  "b": tan(90.5f),
+  "c": tan(int32("90")),
+  "d": tan(int16("0")),
+  "e": tan(int8("-45")),
+  "f": tan(1),
+  "g": tan(null),
+  "h": tan(missing)
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/acos/acos.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/acos/acos.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/acos/acos.1.adm
new file mode 100644
index 0000000..1bbc6b6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/acos/acos.1.adm
@@ -0,0 +1 @@
+{ "a": NaN, "b": 1.0471975511965979, "c": NaN, "d": 1.5707963267948966, "e": 3.141592653589793, "f": 0.0, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/asin/asin.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/asin/asin.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/asin/asin.1.adm
new file mode 100644
index 0000000..3208c37
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/asin/asin.1.adm
@@ -0,0 +1 @@
+{ "a": NaN, "b": 0.5235987755982989, "c": NaN, "d": 0.0, "e": -1.5707963267948966, "f": 1.5707963267948966, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/atan/atan.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/atan/atan.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/atan/atan.1.adm
new file mode 100644
index 0000000..1fb93a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/atan/atan.1.adm
@@ -0,0 +1 @@
+{ "a": 1.4711276743037347, "b": 0.4636476090008061, "c": 1.5607966601082315, "d": 0.0, "e": -0.7853981633974483, "f": 0.7853981633974483, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/cos/cos.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/cos/cos.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/cos/cos.1.adm
new file mode 100644
index 0000000..1ab47ee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/cos/cos.1.adm
@@ -0,0 +1 @@
+{ "a": 0.8141809705265618, "b": -0.8218264239151786, "c": -0.4480736161291702, "d": 1.0, "e": 0.5253219888177297, "f": 0.5403023058681398, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/exp/exp.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/exp/exp.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/exp/exp.1.adm
new file mode 100644
index 0000000..7a2e352
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/exp/exp.1.adm
@@ -0,0 +1 @@
+{ "a": 1.3041808783936323E52, "b": 2.012104870174333E39, "c": 1.2204032943178408E39, "d": 1.0, "e": 2.8625185805493937E-20, "f": 2.718281828459045, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ln/ln.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ln/ln.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ln/ln.1.adm
new file mode 100644
index 0000000..598faa4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/ln/ln.1.adm
@@ -0,0 +1 @@
+{ "a": 4.787491742782046, "b": 4.505349850705881, "c": 4.499809670330265, "d": -Infinity, "e": NaN, "f": 0.0, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/log/log.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/log/log.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/log/log.1.adm
new file mode 100644
index 0000000..5280bf9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/log/log.1.adm
@@ -0,0 +1 @@
+{ "a": 2.0791812460476247, "b": 1.9566485792052033, "c": 1.954242509439325, "d": -Infinity, "e": NaN, "f": 0.0, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sign/sign.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sign/sign.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sign/sign.1.adm
new file mode 100644
index 0000000..7b48b45
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sign/sign.1.adm
@@ -0,0 +1 @@
+{ "a": 1, "b": -1, "c": 1, "d": 0, "e": -1, "f": 1, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sin/sin.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sin/sin.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sin/sin.1.adm
new file mode 100644
index 0000000..0c090f5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sin/sin.1.adm
@@ -0,0 +1 @@
+{ "a": 0.5806111842123143, "b": 0.5697379476169631, "c": 0.8939966636005579, "d": 0.0, "e": -0.8509035245341184, "f": 0.8414709848078965, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sqrt/sqrt.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sqrt/sqrt.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sqrt/sqrt.1.adm
new file mode 100644
index 0000000..7c776f4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/sqrt/sqrt.1.adm
@@ -0,0 +1 @@
+{ "a": 10.954451150103322, "b": 9.513148795220223, "c": 9.486832980505138, "d": 0.0, "e": NaN, "f": 1.0, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/tan/tan.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/tan/tan.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/tan/tan.1.adm
new file mode 100644
index 0000000..62a1053
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/tan/tan.1.adm
@@ -0,0 +1 @@
+{ "a": 0.7131230097859091, "b": -0.6932582489897723, "c": -1.995200412208242, "d": 0.0, "e": -1.6197751905438615, "f": 1.5574077246549023, "g": null }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/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 912b592..9548259 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4234,6 +4234,61 @@
         <!-- <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error> -->
       </compilation-unit>
     </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="acos">
+        <output-dir compare="Text">acos</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="asin">
+        <output-dir compare="Text">asin</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="atan">
+        <output-dir compare="Text">atan</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="cos">
+        <output-dir compare="Text">cos</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="sin">
+        <output-dir compare="Text">sin</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="tan">
+        <output-dir compare="Text">tan</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="exp">
+        <output-dir compare="Text">exp</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="ln">
+        <output-dir compare="Text">ln</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="log">
+        <output-dir compare="Text">log</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="sqrt">
+        <output-dir compare="Text">sqrt</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
+      <compilation-unit name="sign">
+        <output-dir compare="Text">sign</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="open-closed">
     <!--

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/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 97f0ace..d17be1a 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
@@ -199,6 +199,23 @@ public class AsterixBuiltinFunctions {
             "numeric-idiv", 2);
     public static final FunctionIdentifier CARET = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "caret", 2);
     public static final FunctionIdentifier NUMERIC_ABS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "abs", 1);
+    public static final FunctionIdentifier NUMERIC_ACOS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "acos",
+            1);
+    public static final FunctionIdentifier NUMERIC_ASIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "asin",
+            1);
+    public static final FunctionIdentifier NUMERIC_ATAN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "atan",
+            1);
+    public static final FunctionIdentifier NUMERIC_COS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "cos", 1);
+    public static final FunctionIdentifier NUMERIC_SIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sin", 1);
+    public static final FunctionIdentifier NUMERIC_TAN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "tan", 1);
+    public static final FunctionIdentifier NUMERIC_EXP = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "exp", 1);
+    public static final FunctionIdentifier NUMERIC_LN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "ln", 1);
+    public static final FunctionIdentifier NUMERIC_LOG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "log", 1);
+    public static final FunctionIdentifier NUMERIC_SQRT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sqrt",
+            1);
+    public static final FunctionIdentifier NUMERIC_SIGN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sign",
+            1);
+
     public static final FunctionIdentifier NUMERIC_CEILING = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
             "ceiling", 1);
     public static final FunctionIdentifier NUMERIC_FLOOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "floor",
@@ -816,6 +833,17 @@ public class AsterixBuiltinFunctions {
         addPrivateFunction(NUMERIC_MOD, NumericAddSubMulDivTypeComputer.INSTANCE, true);
         addPrivateFunction(NUMERIC_IDIV, AInt64TypeComputer.INSTANCE, true);
         addFunction(NUMERIC_ABS, NumericUnaryFunctionTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_ACOS, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_ASIN, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_ATAN, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_COS, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_SIN, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_TAN, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_EXP, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_LN, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_LOG, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_SQRT, ADoubleTypeComputer.INSTANCE, true);
+        addFunction(NUMERIC_SIGN, AInt8TypeComputer.INSTANCE, true);
         addFunction(NUMERIC_CEILING, NumericUnaryFunctionTypeComputer.INSTANCE, true);
         addFunction(NUMERIC_FLOOR, NumericUnaryFunctionTypeComputer.INSTANCE, true);
         addFunction(NUMERIC_ROUND, NumericUnaryFunctionTypeComputer.INSTANCE, true);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
new file mode 100644
index 0000000..28e54d1
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+
+/**
+ * An abstract class for functions that take a double value as the input and output a double value.
+ */
+abstract class AbstractUnaryNumericDoubleFunctionEval extends AbstractUnaryNumericFunctionEval {
+
+    public AbstractUnaryNumericDoubleFunctionEval(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory,
+            FunctionIdentifier funcID) throws AlgebricksException {
+        super(context, argEvalFactory, funcID);
+    }
+
+    @Override
+    protected void processInt8(byte arg, IPointable resultPointable) throws AlgebricksException {
+        processDouble(arg, resultPointable);
+    }
+
+    @Override
+    protected void processInt16(short arg, IPointable resultPointable) throws AlgebricksException {
+        processDouble(arg, resultPointable);
+    }
+
+    @Override
+    protected void processInt32(int arg, IPointable resultPointable) throws AlgebricksException {
+        processDouble(arg, resultPointable);
+    }
+
+    @Override
+    protected void processInt64(long arg, IPointable resultPointable) throws AlgebricksException {
+        processDouble(arg, resultPointable);
+    }
+
+    @Override
+    protected void processFloat(float arg, IPointable resultPointable) throws AlgebricksException {
+        processDouble(arg, resultPointable);
+    }
+
+    @Override
+    protected abstract void processDouble(double arg, IPointable resultPointable) throws AlgebricksException;
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
new file mode 100644
index 0000000..50ff0de
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
@@ -0,0 +1,211 @@
+/*
+ * 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;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AMutableDouble;
+import org.apache.asterix.om.base.AMutableFloat;
+import org.apache.asterix.om.base.AMutableInt16;
+import org.apache.asterix.om.base.AMutableInt32;
+import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.om.base.AMutableInt8;
+import org.apache.asterix.om.base.IAObject;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
+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.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;
+
+/**
+ * An abstract class for functions that take a numeric value as input and output a numeric value.
+ */
+abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
+
+    // For the argument.
+    protected final IPointable argPtr = new VoidPointable();
+
+    // For the result.
+    protected final AMutableDouble aDouble = new AMutableDouble(0);
+    protected final AMutableFloat aFloat = new AMutableFloat(0);
+    protected final AMutableInt64 aInt64 = new AMutableInt64(0);
+    protected final AMutableInt32 aInt32 = new AMutableInt32(0);
+    protected final AMutableInt16 aInt16 = new AMutableInt16((short) 0);
+    protected final AMutableInt8 aInt8 = new AMutableInt8((byte) 0);
+    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+    private final DataOutput dataOutput = resultStorage.getDataOutput();
+
+    // The evaluator for the argument expression.
+    private final IScalarEvaluator argEval;
+
+    @SuppressWarnings("rawtypes")
+    protected ISerializerDeserializer int8Serde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.AINT8);
+    @SuppressWarnings("rawtypes")
+    protected ISerializerDeserializer int16Serde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.AINT16);
+    @SuppressWarnings("rawtypes")
+    protected ISerializerDeserializer int32Serde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.AINT32);
+    @SuppressWarnings("rawtypes")
+    protected ISerializerDeserializer int64Serde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.AINT64);
+    @SuppressWarnings("rawtypes")
+    protected ISerializerDeserializer floatSerde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.AFLOAT);
+    @SuppressWarnings("rawtypes")
+    protected ISerializerDeserializer doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.ADOUBLE);
+
+    // The function identifier, used for error messages.
+    private final FunctionIdentifier funcID;
+
+    public AbstractUnaryNumericFunctionEval(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory,
+            FunctionIdentifier funcID) throws AlgebricksException {
+        this.argEval = argEvalFactory.createScalarEvaluator(context);
+        this.funcID = funcID;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+        resultStorage.reset();
+        argEval.evaluate(tuple, argPtr);
+        byte[] data = argPtr.getByteArray();
+        int offset = argPtr.getStartOffset();
+
+        if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+            byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
+            processInt8(val, result);
+        } else if (data[offset] == ATypeTag.SERIALIZED_INT16_TYPE_TAG) {
+            short val = AInt16SerializerDeserializer.getShort(data, offset + 1);
+            processInt16(val, result);
+        } else if (data[offset] == ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
+            int val = AInt32SerializerDeserializer.getInt(data, offset + 1);
+            processInt32(val, result);
+        } else if (data[offset] == ATypeTag.SERIALIZED_INT64_TYPE_TAG) {
+            long val = AInt64SerializerDeserializer.getLong(data, offset + 1);
+            processInt64(val, result);
+        } else if (data[offset] == ATypeTag.SERIALIZED_FLOAT_TYPE_TAG) {
+            float val = AFloatSerializerDeserializer.getFloat(data, offset + 1);
+            processFloat(val, result);
+        } else if (data[offset] == ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) {
+            double val = ADoubleSerializerDeserializer.getDouble(data, offset + 1);
+            processDouble(val, result);
+        } else {
+            throw new AlgebricksException(funcID + " expects a numeric input type, but gets "
+                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]));
+        }
+    }
+
+    /**
+     * Processes an int8 argument.
+     *
+     * @param arg
+     *            , the value of the argument.
+     * @param resultPointable
+     *            ,
+     *            the pointable that should be set to the result location.
+     */
+    protected abstract void processInt8(byte arg, IPointable resultPointable) throws AlgebricksException;
+
+    /**
+     * Processes an int16 argument.
+     *
+     * @param arg
+     *            , the value of the argument.
+     * @param resultPointable
+     *            ,
+     *            the pointable that should be set to the result location.
+     */
+    protected abstract void processInt16(short arg, IPointable resultPointable) throws AlgebricksException;
+
+    /**
+     * Processes an int32 argument.
+     *
+     * @param arg
+     *            , the value of the argument.
+     * @param resultPointable
+     *            ,
+     *            the pointable that should be set to the result location.
+     */
+    protected abstract void processInt32(int arg, IPointable resultPointable) throws AlgebricksException;
+
+    /**
+     * Processes an int64 argument.
+     *
+     * @param arg
+     *            , the value of the argument.
+     * @param resultPointable
+     *            ,
+     *            the pointable that should be set to the result location.
+     */
+    protected abstract void processInt64(long arg, IPointable resultPointable) throws AlgebricksException;
+
+    /**
+     * Processes a float argument.
+     *
+     * @param arg
+     *            , the value of the argument.
+     * @param resultPointable
+     *            ,
+     *            the pointable that should be set to the result location.
+     */
+    protected abstract void processFloat(float arg, IPointable resultPointable) throws AlgebricksException;
+
+    /**
+     * Processes a double argument.
+     *
+     * @param arg
+     *            , the value of the argument.
+     * @param resultPointable
+     *            ,
+     *            the pointable that should be set to the result location.
+     */
+    protected abstract void processDouble(double arg, IPointable resultPointable) throws AlgebricksException;
+
+    // Serializes result into the result storage.
+    @SuppressWarnings("unchecked")
+    protected void serialize(IAObject result, ISerializerDeserializer serde, IPointable resultPointable)
+            throws AlgebricksException {
+        try {
+            serde.serialize(result, dataOutput);
+            resultPointable.set(resultStorage);
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericACosDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericACosDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericACosDescriptor.java
new file mode 100644
index 0000000..51609c3
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericACosDescriptor.java
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+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.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.data.std.api.IPointable;
+
+public class NumericACosDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new NumericACosDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.NUMERIC_ACOS;
+    }
+
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        return new IScalarEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new NumericACosEvaluator(ctx, args[0]);
+            }
+        };
+    }
+
+    private class NumericACosEvaluator extends AbstractUnaryNumericDoubleFunctionEval {
+
+        NumericACosEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory)
+                throws AlgebricksException {
+            super(context, argEvalFactory, NumericACosDescriptor.this.getIdentifier());
+        }
+
+        @Override
+        protected void processDouble(double arg, IPointable resultPointable) throws AlgebricksException {
+            aDouble.setValue(Math.acos(arg));
+            serialize(aDouble, doubleSerde, resultPointable);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericASinDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericASinDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericASinDescriptor.java
new file mode 100644
index 0000000..1bd0f6e
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericASinDescriptor.java
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+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.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.data.std.api.IPointable;
+
+public class NumericASinDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new NumericASinDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.NUMERIC_ASIN;
+    }
+
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        return new IScalarEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new NumericASinEvaluator(ctx, args[0]);
+            }
+        };
+    }
+
+    private class NumericASinEvaluator extends AbstractUnaryNumericDoubleFunctionEval {
+
+        NumericASinEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory)
+                throws AlgebricksException {
+            super(context, argEvalFactory, NumericASinDescriptor.this.getIdentifier());
+        }
+
+        @Override
+        protected void processDouble(double arg, IPointable resultPointable) throws AlgebricksException {
+            aDouble.setValue(Math.asin(arg));
+            serialize(aDouble, doubleSerde, resultPointable);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericATanDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericATanDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericATanDescriptor.java
new file mode 100644
index 0000000..2d5a359
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericATanDescriptor.java
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+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.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.data.std.api.IPointable;
+
+public class NumericATanDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+    private static final long serialVersionUID = 1L;
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new NumericATanDescriptor();
+        }
+    };
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return AsterixBuiltinFunctions.NUMERIC_ATAN;
+    }
+
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        return new IScalarEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new NumericATanEvaluator(ctx, args[0]);
+            }
+        };
+    }
+
+    private class NumericATanEvaluator extends AbstractUnaryNumericDoubleFunctionEval {
+
+        NumericATanEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory)
+                throws AlgebricksException {
+            super(context, argEvalFactory, NumericATanDescriptor.this.getIdentifier());
+        }
+
+        @Override
+        protected void processDouble(double arg, IPointable resultPointable) throws AlgebricksException {
+            aDouble.setValue(Math.atan(arg));
+            serialize(aDouble, doubleSerde, resultPointable);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/7cb2f9ae/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
index 373547e..69edb6e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
@@ -23,40 +23,16 @@
  */
 package org.apache.asterix.runtime.evaluators.functions;
 
-import java.io.DataOutput;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.AMutableDouble;
-import org.apache.asterix.om.base.AMutableFloat;
-import org.apache.asterix.om.base.AMutableInt16;
-import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.AMutableInt8;
 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.common.exceptions.NotImplementedException;
 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 NumericAbsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
     private static final long serialVersionUID = 1L;
@@ -73,86 +49,83 @@ public class NumericAbsDescriptor extends AbstractScalarFunctionDynamicDescripto
     }
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new NumericAbsEvaluator(ctx, args[0]);
+            }
+        };
+    }
 
-                return new IScalarEvaluator() {
+    private class NumericAbsEvaluator extends AbstractUnaryNumericFunctionEval {
 
-                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
-                    private DataOutput out = resultStorage.getDataOutput();
-                    private IPointable argPtr = new VoidPointable();
-                    private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-                    private AMutableDouble aDouble = new AMutableDouble(0);
-                    private AMutableFloat aFloat = new AMutableFloat(0);
-                    private AMutableInt64 aInt64 = new AMutableInt64(0);
-                    private AMutableInt32 aInt32 = new AMutableInt32(0);
-                    private AMutableInt16 aInt16 = new AMutableInt16((short) 0);
-                    private AMutableInt8 aInt8 = new AMutableInt8((byte) 0);
-                    @SuppressWarnings("rawtypes")
-                    private ISerializerDeserializer serde;
+        NumericAbsEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory)
+                throws AlgebricksException {
+            super(context, argEvalFactory, NumericAbsDescriptor.this.getIdentifier());
+        }
+
+        @Override
+        protected void processInt8(byte arg, IPointable resultPointable) throws AlgebricksException {
+            if (arg >= 0) {
+                resultPointable.set(argPtr);
+                return;
+            }
+            aInt8.setValue((byte) (0 - arg));
+            serialize(aInt8, int8Serde, resultPointable);
+        }
 
-                    @SuppressWarnings("unchecked")
-                    @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-                        resultStorage.reset();
-                        eval.evaluate(tuple, argPtr);
-                        byte[] data = argPtr.getByteArray();
-                        int offset = argPtr.getStartOffset();
+        @Override
+        protected void processInt16(short arg, IPointable resultPointable) throws AlgebricksException {
+            if (arg >= 0) {
+                resultPointable.set(argPtr);
+                return;
+            }
+            aInt16.setValue((short) (0 - arg));
+            serialize(aInt16, int16Serde, resultPointable);
+        }
 
-                        try {
-                            if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
-                                serde = AqlSerializerDeserializerProvider.INSTANCE
-                                        .getSerializerDeserializer(BuiltinType.AINT8);
-                                byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
-                                aInt8.setValue((val <= 0) ? (byte) (0 - val) : val);
-                                serde.serialize(aInt8, out);
-                            } else if (data[offset] == ATypeTag.SERIALIZED_INT16_TYPE_TAG) {
-                                serde = AqlSerializerDeserializerProvider.INSTANCE
-                                        .getSerializerDeserializer(BuiltinType.AINT16);
-                                short val = AInt16SerializerDeserializer.getShort(data, offset + 1);
-                                aInt16.setValue((val <= 0) ? (short) (0 - val) : val);
-                                serde.serialize(aInt16, out);
-                            } else if (data[offset] == ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
-                                serde = AqlSerializerDeserializerProvider.INSTANCE
-                                        .getSerializerDeserializer(BuiltinType.AINT32);
-                                int val = AInt32SerializerDeserializer.getInt(data, offset + 1);
-                                aInt32.setValue((val <= 0) ? (0 - val) : val);
-                                serde.serialize(aInt32, out);
-                            } else if (data[offset] == ATypeTag.SERIALIZED_INT64_TYPE_TAG) {
-                                serde = AqlSerializerDeserializerProvider.INSTANCE
-                                        .getSerializerDeserializer(BuiltinType.AINT64);
-                                long val = AInt64SerializerDeserializer.getLong(data, offset + 1);
-                                aInt64.setValue((val <= 0L) ? (0L - val) : val);
-                                serde.serialize(aInt64, out);
-                            } else if (data[offset] == ATypeTag.SERIALIZED_FLOAT_TYPE_TAG) {
-                                serde = AqlSerializerDeserializerProvider.INSTANCE
-                                        .getSerializerDeserializer(BuiltinType.AFLOAT);
-                                float val = AFloatSerializerDeserializer.getFloat(data, offset + 1);
-                                aFloat.setValue((val <= 0.0f) ? 0.0f - val : val);
-                                serde.serialize(aFloat, out);
-                            } else if (data[offset] == ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) {
-                                serde = AqlSerializerDeserializerProvider.INSTANCE
-                                        .getSerializerDeserializer(BuiltinType.ADOUBLE);
-                                double val = ADoubleSerializerDeserializer.getDouble(data, offset + 1);
-                                aDouble.setValue((val <= 0.0D) ? 0.0D - val : val);
-                                serde.serialize(aDouble, out);
-                            } else {
-                                throw new NotImplementedException(
-                                        AsterixBuiltinFunctions.NUMERIC_ABS.getName() + ": not implemented for "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]));
-                            }
-                        } catch (HyracksDataException e) {
-                            throw new AlgebricksException(e);
-                        }
-                        result.set(resultStorage);
-                    }
-                };
+        @Override
+        protected void processInt32(int arg, IPointable resultPointable) throws AlgebricksException {
+            if (arg >= 0) {
+                resultPointable.set(argPtr);
+                return;
             }
-        };
+            aInt32.setValue(0 - arg);
+            serialize(aInt32, int32Serde, resultPointable);
+        }
+
+        @Override
+        protected void processInt64(long arg, IPointable resultPointable) throws AlgebricksException {
+            if (arg >= 0) {
+                resultPointable.set(argPtr);
+                return;
+            }
+            aInt64.setValue(0L - arg);
+            serialize(aInt64, int64Serde, resultPointable);
+        }
+
+        @Override
+        protected void processFloat(float arg, IPointable resultPointable) throws AlgebricksException {
+            if (arg >= 0.0f) {
+                resultPointable.set(argPtr);
+                return;
+            }
+            aFloat.setValue(0.0f - arg);
+            serialize(aFloat, floatSerde, resultPointable);
+        }
+
+        @Override
+        protected void processDouble(double arg, IPointable resultPointable) throws AlgebricksException {
+            if (arg >= 0.0d) {
+                resultPointable.set(argPtr);
+                return;
+            }
+            aDouble.setValue(0.0d - arg);
+            serialize(aDouble, doubleSerde, resultPointable);
+        }
     }
 
 }


Mime
View raw message