Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

IMPALA: Adding PRIMARY KEY while doing CREATE TABLE AS SELECT

Highlighted

IMPALA: Adding PRIMARY KEY while doing CREATE TABLE AS SELECT

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
Highlighted

Re: IMPALA: Adding PRIMARY KEY while doing CREATE TABLE AS SELECT

Rising Star
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.

Re: IMPALA: Adding PRIMARY KEY while doing CREATE TABLE AS SELECT

Explorer

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.

Don't have an account?
Coming from Hortonworks? Activate your account here