pig tutorial - apache pig tutorial - Apache Pig - COS() - pig latin - apache pig - pig hadoop
What is COS() function?
- The cosine function is one of the basic functions encountered in trigonometry (the others being the cosecant, cotangent, secant, sine, and tangent).
- Let be an angle measured counterclockwise from the x-axis along the arc of the unit circle. Then is the horizontal coordinate of the arc endpoint.
Learn apache pig - apache pig tutorial - cos function in apache pig - apache pig examples - apache pig programs
COS() function in Apache pig
- The COS() function of Apache Pig Latin is used to calculate the cosine value of a specified expression.
Syntax:
Example:
- Ensure that we have a file named wikitechy_math.txt in the HDFS directory /pig_data/.
- This file contains integer and floating point values is given below.
wikitechy_math.txt
- We have loaded this file into Pig with a relation named math_data as shown below.
- We are calculate the cosine values of the contents of the wikitechy_math.txt file using COS() function as given below.
- Above statement stores the result in the relation named cos_data
Verification:
- Now you can verify the contents of the relation using the Dump operator as shown below.
Output:
The output shows that the result in the file>cos_data.