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.

Any work round to avoid duplicate records in impala for Primary key column

Solved Go to solution
Highlighted

Any work round to avoid duplicate records in impala for Primary key column

Explorer

Appreciate if any work round to avoid duplicate records in impala for Primary key column.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Any work round to avoid duplicate records in impala for Primary key column

Champion

Impala does not have a concept of PK .However You have two options 

down the road if you want to implement delete single row you cant perform them on Hive / Impala . So you can implement using Impala-kudu format . Kudu format you can create table with primary key , plus you perform single row delete. 

 

or the hard way to achive this is to 

 

 

STEP 1

CREATE TABLE Sample ( name STRING, street STRING, RD123 Timestamp ,(Assume this is unique since we dont have Pk) ) STEP 2
Perform the LOAD DATA INTO Sample
STEP 3 - Create another table
Create table sample_no_dupli AS select SELECT col1,col2,MAX(RD123) AS createdate FROM JLT_STAHING GROUP BY name,street

 

 

 

7 REPLIES 7

Re: Any work round to avoid duplicate records in impala for Primary key column

Champion

Are you asking pertain to inseration or reterival of data ?

Re: Any work round to avoid duplicate records in impala for Primary key column

Explorer

thinking of avoidng duplicates while insertion if this won't cause performacne issue.

Re: Any work round to avoid duplicate records in impala for Primary key column

Champion

@Msdhan

 

https://www.cloudera.com/documentation/enterprise/5-3-x/topics/impala_porting.html

 

According to the above link, Take out any CREATE INDEXDROP INDEX, and ALTER INDEX statements, and equivalent ALTER TABLEstatements. Remove any INDEXKEY, or PRIMARY KEY clauses from CREATE TABLE and ALTER TABLE statements. Impala is optimized for bulk read operations for data warehouse-style queries, and therefore does not support indexes for its tables.

 

Yes in general, you cannot achieve both Performance and Indexing. So if possible, you can try to control duplicate in the source (select) portion instead of target (insert) portion

 

Ex:

insert into table trg_table 

select * from src_table

 

 

 

Re: Any work round to avoid duplicate records in impala for Primary key column

Explorer
Thanks Saranvisa for this explanation

Re: Any work round to avoid duplicate records in impala for Primary key column

Champion

Impala does not have a concept of PK .However You have two options 

down the road if you want to implement delete single row you cant perform them on Hive / Impala . So you can implement using Impala-kudu format . Kudu format you can create table with primary key , plus you perform single row delete. 

 

or the hard way to achive this is to 

 

 

STEP 1

CREATE TABLE Sample ( name STRING, street STRING, RD123 Timestamp ,(Assume this is unique since we dont have Pk) ) STEP 2
Perform the LOAD DATA INTO Sample
STEP 3 - Create another table
Create table sample_no_dupli AS select SELECT col1,col2,MAX(RD123) AS createdate FROM JLT_STAHING GROUP BY name,street

 

 

 

Re: Any work round to avoid duplicate records in impala for Primary key column

Explorer

csguna, appreciate your inputs. will try this.

Re: Any work round to avoid duplicate records in impala for Primary key column

Champion

@Msdhan You Welcome :))