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




What is CEIL() function in Apache Pig ?

  • CEIL() function is used to get the value of an expression rounded up to the nearest integer.
 Apache Pig celi

Learn Apache Pig - Apache Pig tutorial - Apache Pig celi - Apache Pig examples - Apache Pig programs

Syntax:

grunt> CEIL(expression)

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 are given below.

wikitechy_math.txt

4
13 
9 
4.5 
7.9 
3.1 
  • You have loaded this file into Pig with a relation named math_data is given below.
grunt> math_data = LOAD 'hdfs://localhost:9000/pig_data/wikitechy_math.txt' USING          PigStorage(',')
   as (data:float);
  • You compute the ceil values of the contents of the wilitechy_math.txt file using CEIL() function as given below.
grunt> ceil_data = foreach math_data generate (data), CEIL(data);
  • The above statement stores the result in the relation named ceil_data.

Verification:

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

Output:

  • The output shows that the result in the file ceil_data.
(4.0,4.0) 
(13.0,13.0) 
(9.0,9.0) 
(4.5,5.0) 
(7.9,8.0) 
(3.1,4.0)

Related Searches to Apache Pig CEIL()