- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to use regexp_replace in hive to remove special character ^
- Labels:
-
Apache Hive
Created ‎06-27-2018 05:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an expression like
HA^G^FER$$JY
I would like to replace the all ^ with $.
How do I do it. I tried all methods but this isn't working.
Most common error I get is :
java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
Created ‎06-27-2018 09:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with the below syntax
hive> select regexp_replace('HA^G^FER$JY',"\\^","\\$"); +---------------+--+ | _c0 | +---------------+--+ | HA$G$FER$JY | +---------------+--+
As ^,$ are reserved keys for Regex so use two back slashes in regexp_replace function.
Created ‎06-27-2018 09:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with the below syntax
hive> select regexp_replace('HA^G^FER$JY',"\\^","\\$"); +---------------+--+ | _c0 | +---------------+--+ | HA$G$FER$JY | +---------------+--+
As ^,$ are reserved keys for Regex so use two back slashes in regexp_replace function.
