Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Solved
Go to solution
How do I remove currency symbol from string and convert into int in hive? EXAMPLE (124$ INTO 124)
Labels:
- Labels:
-
Apache Hive
Explorer
Created ‎01-16-2019 09:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1 ACCEPTED SOLUTION
Master Guru
Created ‎01-16-2019 10:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Venkat
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 | +------+--+
1 REPLY 1
Master Guru
Created ‎01-16-2019 10:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Venkat
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 | +------+--+
