bunny
bunny

Reputation: 354

Replace all values in a column of hive table with a given value

I have a hive table with schema -

customer_id string
country string
start_date string
end_date string

I want to replace all the values with a given string in end_date column which is in yyyy-mm-dd format but stored as a string.

Looking at the hive functions, I found out two of them - regexp_replace and translate. Refer -Hive wiki

Upvotes: 1

Views: 2148

Answers (1)

Anil
Anil

Reputation: 420

@bunny: You will not be able to update the existing column using the UDF's mentioned. if you want to update the column, you will have to use UPDATE (provided that you have hive >= 0.14 AND the table is created accoringly - fileformat-clustering-bucketing). I'm sure you're not looking for this approach !

Both the udfs mentioned ( regexp_replace and translate) are used to obtain the required output but not replace the existing data.

The only option I see is to overwrite the complete table with the updated column something

Upvotes: 1

Related Questions