Created 05-29-2017 07:42 AM
I am trying to create a table with Bucketing from another table using select but it fails. Here is my query
create table tmp CLUSTERED BY (key) INTO 256 BUCKETS as select * from link_table limit 10;
And I get the below error
FAILED: SemanticException [Error 10068]: CREATE-TABLE-AS-SELECT does not support partitioning in the target table
link_table is already bucketed. I have also set the property to enforce bucketing.
I am not sure if bucketing is supported with CTAS. Is there a way I can get this working?
Created 05-29-2017 11:23 AM
Refer to the link for more details:-
Created 05-29-2017 11:58 AM
If I create a plain target table would I be able to alter the table later? What I mean is, create a plain table and then alter the table to add the buckets? If yes, how?
Created 06-06-2017 03:38 PM
@Alex Raj Can you please accept the answer if it resolved the issue?
Created 05-31-2017 07:08 AM
You can use the below command to alter the table to add buckets:-
ALTER TABLE table_name CLUSTERED BY (col_name, col_name, ...) [SORTED BY (col_name, ...)]
INTO num_buckets BUCKETS
Please note that the above command will only modify Hive's metadata, and will NOT reorganize or reformat existing data.
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL
Created 08-01-2018 07:19 PM
https://cwiki.apache.org/confluence/display/Hive/DynamicPartitions
But here it states that , we can create partition table from CTAS by specifying the schema including partitioning columns in the create-clause. Can we create bucketed table by specifying the schema?
CREATE TABLE T (key
int
, value string) PARTITIONED BY (ds string, hr
int
) AS
SELECT key, value, ds, hr
FROM srcpart ;