Index: ql/src/test/results/clientpositive/udf_sin.q.out =================================================================== --- ql/src/test/results/clientpositive/udf_sin.q.out (revision 0) +++ ql/src/test/results/clientpositive/udf_sin.q.out (revision 0) @@ -0,0 +1,10 @@ +query: SELECT sin(null) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/2092943307/10000 +NULL +query: SELECT sin(0.98), sin(1.57), sin(-0.5) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/1611665044/10000 +0.8304973704919705 0.9999996829318346 -0.479425538604203 Index: ql/src/test/results/clientpositive/udf_acos.q.out =================================================================== --- ql/src/test/results/clientpositive/udf_acos.q.out (revision 0) +++ ql/src/test/results/clientpositive/udf_acos.q.out (revision 0) @@ -0,0 +1,20 @@ +query: SELECT acos(null) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/952728720/10000 +NULL +query: SELECT acos(0) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/1631791047/10000 +1.5707963267948966 +query: SELECT acos(-0.5), asin(0.66) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/1922816852/10000 +2.0943951023931957 0.7208187608700897 +query: SELECT acos(2) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/296909393/10000 +NaN Index: ql/src/test/results/clientpositive/udf_cos.q.out =================================================================== --- ql/src/test/results/clientpositive/udf_cos.q.out (revision 0) +++ ql/src/test/results/clientpositive/udf_cos.q.out (revision 0) @@ -0,0 +1,10 @@ +query: SELECT cos(null) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/1815431857/10000 +NULL +query: SELECT cos(0.98), cos(1.57), cos(-0.5) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/1350046602/10000 +0.5570225467662173 7.963267107332633E-4 0.8775825618903728 Index: ql/src/test/results/clientpositive/udf_asin.q.out =================================================================== --- ql/src/test/results/clientpositive/udf_asin.q.out (revision 0) +++ ql/src/test/results/clientpositive/udf_asin.q.out (revision 0) @@ -0,0 +1,20 @@ +query: SELECT asin(null) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/991103884/10000 +NULL +query: SELECT asin(0) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/1020681434/10000 +0.0 +query: SELECT asin(-0.5), asin(0.66) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/702113357/10000 +-0.5235987755982989 0.7208187608700897 +query: SELECT asin(2) +FROM src LIMIT 1 +Input: default/src +Output: file:/home/kmangla/hive/build/ql/tmp/985907824/10000 +NaN Index: ql/src/test/queries/clientpositive/udf_sin.q =================================================================== --- ql/src/test/queries/clientpositive/udf_sin.q (revision 0) +++ ql/src/test/queries/clientpositive/udf_sin.q (revision 0) @@ -0,0 +1,5 @@ +SELECT sin(null) +FROM src LIMIT 1; + +SELECT sin(0.98), sin(1.57), sin(-0.5) +FROM src LIMIT 1; Index: ql/src/test/queries/clientpositive/udf_acos.q =================================================================== --- ql/src/test/queries/clientpositive/udf_acos.q (revision 0) +++ ql/src/test/queries/clientpositive/udf_acos.q (revision 0) @@ -0,0 +1,11 @@ +SELECT acos(null) +FROM src LIMIT 1; + +SELECT acos(0) +FROM src LIMIT 1; + +SELECT acos(-0.5), asin(0.66) +FROM src LIMIT 1; + +SELECT acos(2) +FROM src LIMIT 1; Index: ql/src/test/queries/clientpositive/udf_asin.q =================================================================== --- ql/src/test/queries/clientpositive/udf_asin.q (revision 0) +++ ql/src/test/queries/clientpositive/udf_asin.q (revision 0) @@ -0,0 +1,11 @@ +SELECT asin(null) +FROM src LIMIT 1; + +SELECT asin(0) +FROM src LIMIT 1; + +SELECT asin(-0.5), asin(0.66) +FROM src LIMIT 1; + +SELECT asin(2) +FROM src LIMIT 1; Index: ql/src/test/queries/clientpositive/udf_cos.q =================================================================== --- ql/src/test/queries/clientpositive/udf_cos.q (revision 0) +++ ql/src/test/queries/clientpositive/udf_cos.q (revision 0) @@ -0,0 +1,5 @@ +SELECT cos(null) +FROM src LIMIT 1; + +SELECT cos(0.98), cos(1.57), cos(-0.5) +FROM src LIMIT 1; Index: ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (revision 796865) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (working copy) @@ -65,6 +65,10 @@ registerUDF("ln", UDFLn.class, OperatorType.PREFIX, false); registerUDF("log2", UDFLog2.class, OperatorType.PREFIX, false); + registerUDF("sin",UDFSin.class, OperatorType.PREFIX, false); + registerUDF("asin",UDFAsin.class, OperatorType.PREFIX, false); + registerUDF("cos",UDFCos.class, OperatorType.PREFIX, false); + registerUDF("acos",UDFAcos.class, OperatorType.PREFIX, false); registerUDF("log10", UDFLog10.class, OperatorType.PREFIX, false); registerUDF("log", UDFLog.class, OperatorType.PREFIX, false); registerUDF("exp", UDFExp.class, OperatorType.PREFIX, false); Index: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFCos.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFCos.java (revision 0) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFCos.java (revision 0) @@ -0,0 +1,48 @@ +/** + * 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.hadoop.hive.ql.udf; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.UDF; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; + + +public class UDFCos extends UDF { + + private static Log LOG = LogFactory.getLog(UDFCos.class.getName()); + + DoubleWritable result = new DoubleWritable(); + + public UDFCos() { + } + + /** + * Take Cosine of a + */ + public DoubleWritable evaluate(DoubleWritable a) { + if (a == null) { + return null; + } else { + result.set(Math.cos(a.get())); + return result; + } + } + +} Index: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFAsin.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFAsin.java (revision 0) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFAsin.java (revision 0) @@ -0,0 +1,48 @@ +/** + * 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.hadoop.hive.ql.udf; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.UDF; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; + + +public class UDFAsin extends UDF { + + private static Log LOG = LogFactory.getLog(UDFAsin.class.getName()); + + DoubleWritable result = new DoubleWritable(); + + public UDFAsin() { + } + + /** + * Take Arc Sine of a in radians. + */ + public DoubleWritable evaluate(DoubleWritable a) { + if (a == null) { + return null; + } else { + result.set(Math.asin(a.get())); + return result; + } + } + +} Index: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFAcos.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFAcos.java (revision 0) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFAcos.java (revision 0) @@ -0,0 +1,48 @@ +/** + * 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.hadoop.hive.ql.udf; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.UDF; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; + + +public class UDFAcos extends UDF { + + private static Log LOG = LogFactory.getLog(UDFAcos.class.getName()); + + DoubleWritable result = new DoubleWritable(); + + public UDFAcos() { + } + + /** + * Take Arc Cosine of a in radians. + */ + public DoubleWritable evaluate(DoubleWritable a) { + if (a == null) { + return null; + } else { + result.set(Math.acos(a.get())); + return result; + } + } + +} Index: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSin.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSin.java (revision 0) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSin.java (revision 0) @@ -0,0 +1,48 @@ +/** + * 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.hadoop.hive.ql.udf; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.UDF; +import org.apache.hadoop.hive.serde2.io.DoubleWritable; + + +public class UDFSin extends UDF { + + private static Log LOG = LogFactory.getLog(UDFSin.class.getName()); + + DoubleWritable result = new DoubleWritable(); + + public UDFSin() { + } + + /** + * Take Sine of a. + */ + public DoubleWritable evaluate(DoubleWritable a) { + if (a == null) { + return null; + } else { + result.set(Math.sin(a.get())); + return result; + } + } + +}