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.
 cos function in apache pig

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.


grunt> COS(expression)


  • 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.


  • We have loaded this file into Pig with a relation named math_data as shown below.
grunt> math_data = LOAD 'hdfs://localhost:9000/pig_data/wikitechy_math.txt' USING PigStorage(',')
   as (data:float)
  • We are calculate the cosine values of the contents of the wikitechy_math.txt file using COS() function as given below.
grunt> cos_data = foreach math_data generate (data), COS(data);
  • Above statement stores the result in the relation named cos_data


  • Now you can verify the contents of the relation using the Dump operator as shown below.
grunt> Dump cos_data;


The output shows that the result in the file>cos_data.


Related Searches to Apache Pig - COS()

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.