pig tutorial - apache pig tutorial - Apache Pig - FLOOR() - pig latin - apache pig - pig hadoop
What is FLOOR() function?
The floor function , also called the greatest integer function or integer value gives the largest integer less than or equal to.

Learn apache pig - apache pig tutorial - floor graph in apache pig - apache pig examples - apache pig programs
FLOOR() function in Apache Pig
- The FLOOR() function is used to calculate the value of an expression rounded down to the nearest integer
Syntax:
grunt> FLOOR(expression)
Example
- Ensure that we have a file named wikitechy_floor.txt in the HDFS directory /pig_data/.
- This file contains integer and floating point values as shown below.
wikitecyhy_floor.tx
2
13
9
4.5
8.8
7.1
- We have loaded this file into Pig with a relation named floor_data as shown below.
grunt> floor_data = LOAD 'hdfs://localhost:9000/pig_wikitechy_floop.txt' USING PigStorage(',')
as (data:float);
- We can generate the floor values of the contents of the wikitechy_math.txt file using FLOOR() as given below.
grunt> floor_data = foreach math_data generate (data), FLOOR(data);
Verification:
- Now you can verify the contents of the relation using the Dump operator as given below.
grunt> Dump floor_data;
Output:
The output shows that the result in the file>floor_data.
(2.0,2.0)
(13.0,13.0)
(9.0,9.0)
(4.5,4.0)
(8.8,8.0)
(7.2,7.0)