java - Generate unique customer id / insert unique rows in hive -



java - Generate unique customer id / insert unique rows in hive -

i need insert unique rows hive table based on client name , address.

is there anyway can generate unique value using client name , address? looking generate unique_value column below , select rows distinct unique_value.

for illustration below want generate unique_value column

{customer_name} {address} {unique_value}

omar street1 111

ryan stree2 222

omar street1 111

or other approaches appreciated!.

you can seek 2 things. can either seek having uuid generate unique id each row. do:

select reflect("java.util.uuid", "randomuuid"), customer_name, address, unique_value table_name

however if planning have unique key based on name , address, can concat both fields , take hash of resulting string (see details of hash function here: https://cwiki.apache.org/confluence/display/hive/languagemanual+udf). ensure same name , address gets same key. query should sufficient:

select customer_name, address, hash(concat(customer_name, address)) table_name

java mysql sql hadoop hive

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -