ORDER BY and SORT BY Clause in Hive
Here we can create a Table and perform live operation .
Follow all steps which is as follow :
create table DeveloperIndian(Id int, Name string , Salary float, Department string)
row format delimited
fields terminated by ',' ;
Load the data into the table.
load data local inpath '/home/codegyani/hive/developerIndian_data' into table DeveloperIndiavn;
Run the order by Query
ORDER BY performs a total ordering of the query result set. This means that all the data is
passed through a single reducer, which may take an unacceptably long time to execute for
larger data sets.
select * from DeveloperIndian order by salary desc;
Run the Sort by Query
SORT BY orders the data only within each reducer, thereby performing a local ordering, where each reducer’s output will be sorted. You will not achieve a total ordering on the dataset. Better performance is traded for total ordering.
select * from DeveloperIndian sort by salary desc;