pig tutorial - apache pig tutorial - Apache Pig - EXP() - pig latin - apache pig - pig hadoop

What is EXP() function?

  • The exponential function, exp(x), calculates the value of e to the power of x, where e is the base of the natural logarithm, 2.718281828... .
  • You can enter the command exp using either the 1-D or 2-D calling sequence.
  • For example, exp(-1) is equivalent to . ... exp(1) is used instead.
 exp function in apache pig

Learn apache pig - apache pig tutorial - exp function in apache pig - apache pig examples - apache pig programs

EXP() function in Apache Pig

  • The EXP() function of Pig Latin is used to get the Euler’s number e raised to the power of x for given expression.


grunt> EXP(expression)


  • Ensure that we have a file named wikitechy_exp.txt in the HDFS directory /pig_data/.
  • This file contains integer and floating point values as shown below.


  • You have loaded this file into Pig with a relation named exp_data as given below.
grunt> exp_data = LOAD 'hdfs://localhost:9000/pig_data/wikitechy_exp.txt' USING PigStorage(',')
   as (data:float);
  • You compute the exp values of the contents of the wikitechy_exp.txt file using EXP() function as given below.
grunt> exp_data = foreach math_data generate (data), EXP(data);

The above statement stores the result in the relation named exp_data.


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


The output shows that the result in the file>exp _data.


Related Searches to Apache Pig - EXP()