Yes. SORTED BY can only be used with CLUSTERED BY .. into ’n’ buckets

If you want to insert data in a sorted order on a specific column, you can add 
ORDER BY/SORT BY to the select query for the column that you want to sort. 
ORDER BY will use single reducer but you will get global ordering where SORT BY 
is local ordering and can use multiple reducers.

Thanks
Prasanth
On Nov 3, 2015, at 1:54 PM, Sergey Shelukhin 
<ser...@hortonworks.com<mailto:ser...@hortonworks.com>> wrote:

IIRC sorted by is only supported on bucketed tables.

From: Mich Talebzadeh <m...@peridale.co.uk<mailto:m...@peridale.co.uk>>
Reply-To: "user@hive.apache.org<mailto:user@hive.apache.org>" 
<user@hive.apache.org<mailto:user@hive.apache.org>>
Date: Tuesday, November 3, 2015 at 01:23
To: "user@hive.apache.org<mailto:user@hive.apache.org>" 
<user@hive.apache.org<mailto:user@hive.apache.org>>
Subject: create table as ORC with SORTED BY fails

Hi,

Any idea why this simple create table fails?

hive> create table test (
    >  owner                   varchar(30)
    > ,object_name             varchar(30)
    > ,object_id               bigint
    > )
    > SORTED BY (object_id)
    > STORED AS ORC
    >  TBLPROPERTIES ("orc.compress"="SNAPPY"
    > ,"orc.create,index"="true");
FAILED: ParseException line 6:0 missing EOF at 'SORTED' near ')'

If I remove SORTED BY clause it works!

Thanks

http://talebzadehmich.wordpress.com<http://talebzadehmich.wordpress.com/>

NOTE: The information in this email is proprietary and confidential. This 
message is for the designated recipient only, if you are not the intended 
recipient, you should destroy it immediately. Any information in this message 
shall not be understood as given or endorsed by Peridale Technology Ltd, its 
subsidiaries or their employees, unless expressly so stated. It is the 
responsibility of the recipient to ensure that this email is virus free, 
therefore neither Peridale Ltd, its subsidiaries nor their employees accept any 
responsibility.

Reply via email to