I'm trying to select specific fields in a hive table and save the result in a text file. The main problem is that, for one of the fields in the table, I want to add prefix in all the rows of a particular column. Currently, all rows of that column in the hive table are in the form 00yyhhgdbdbd
. Now, I want to write my select statement and prefix this row with AB_
. And in my text file, it will be of the form AB_00yyhhgdbdbd
). How can I handle this Please?
AB_00yyhhgdbdbd
AB_00yyhhgdbdbd
AB_00yyhhgdbdbd
Any functions to handle this in hive?
Use concat() function to concatenate with AB_ in the select
select concat('AB_', id) from your_table;
As of Hive 2.2.0. you can use || operator instead of concat:
select 'AB_'||id from your_table;