The TAN() function is used to calculate the trigonometric tangent of a given expression (angle).
Here is the syntax of the TAN() function.
Assume that there is a file named math.txt in the HDFS directory /pig_data/. This file contains integer and floating point values as shown below.
5 16 9 2.5 5.9 3.1
And, 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/math.txt' USING PigStorage(',') as (data:float);
Let us now calculate the tan values of the contents of the math.txt file using TAN() function as shown below.
grunt> tan_data = foreach math_data generate (data), TAN(data);
The above statement stores the result in the relation named tan_data. Verify the contents of the relation using the Dump operator as shown below.
grunt> Dump tan_data; (5.0,-3.380515006246586) (16.0,0.3006322420239034) (9.0,-0.45231565944180985) (2.5,-0.7470222972386603) (5.9,-0.4031107890087444) (3.1,-0.041616750118239246)