I am working on Hive 0.13 in MapR distro. I am seeing a weird issue when i run the following query in hive using the hive -e option.
Below is my query :
select regexp_replace('$60,825.48','\\$|\,','');
The above query works fine when I run from the hive shell directly and gives desired the output as 60825.48.
Now, When I run the same using the hive -e as follows :
hive -e "select regexp_replace('$60,825.48','\\$|\,','');"
Total MapReduce CPU Time Spent: 890 msec
OK
0825.48
Time taken: 7.813 seconds, Fetched: 1 row(s)
The "6" gets trimmed off from the desired output.
Also, The same works fine with Hive -f option too.
Could you please help me identify the issue?
Try this
hive -e 'select regexp_replace("$60,825.48","\\$|\,","");'
If your objective is to remove everything except numbers and '.', then you can try this as well
hive -e 'select regexp_replace("$60,825.48","[^0-9.]","");'