Created on 01-16-2019 09:02 PM - last edited on 06-07-2026 11:39 PM by VidyaSargur
How do I remove a currency symbol from a string and convert it into an int in Hive? For example, how do I change '124$' into 124?
Created 01-16-2019 10:49 PM
Use regexp_replace function in hive to replace $ with '' then cast to int.
Example:
select int(regexp_replace(string("124$"),'\\$','')); +------+--+ | _c0 | +------+--+ | 124 | +------+--+
(or)
Starting from Hive-1.3 version use replace function.
select int(replace(string("124$"),'$','')); +------+--+ | _c0 | +------+--+ | 124 | +------+--+
View solution in original post