Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

IMPALA: Adding PRIMARY KEY while doing CREATE TABLE AS SELECT

avatar
Explorer

I am creating an Impala table stored as Kudu using the command as mentioned below.

 

create table if not exists bit_nnet.bit_feature_matrix_100
comment 'Table to store the feature matrix'
stored as kudu
as
select * from bit_nnet.bit_feature_matrix_100_ext;

 

The source table "feature_matrix_100_ext" is a regular Impala external table which does not have a primary key. Hence, when I'm trying to create the table, getting an error that a primary key is required for a Kudu table (which is quite natural)!

 

The following is the error I'm getting:

AnalysisException: A primary key is required for a Kudu table.

Any idea how to overcome this issue?

 

Note: I am using the Hue interface for doing the aforesaid

2 REPLIES 2

avatar
Expert Contributor
There's no workaround for this yet. For the time being, every Kudu table must have a primary key, and it must be populated if loading data from a table without primary keys.

avatar
Rising Star

there is a uuid function in impala that you can use to generate surrogate keys for kudu. or you can write an impala udf to generate unique bigints.