hive replaceall用法
`REPLACEALL` is a function in Hive that is used to replace all occurrences of a substring in a string with another substring. The basic syntax of `REPLACEALL` function in Hive is as follows:
REPLACEALL(string, pattern, replacement)
Where:
- `string` is the input string where the replacements need to be made.
- `pattern` is the substring that needs to be replaced.
replaceall()- `replacement` is the substring that will be substituted for `pattern` in `string`.
Example:
Suppose we have a table `employees` with a column `full_name` that contains the full names of employees:
+-+
full_name
+-+
John Doe
Jane Smith
Michael Johnson
Sarah Williams
+-+
If we want to replace the space (" ") between first name and last name with an underscore ("_"), we can use the `REPLACEALL` function as follows:
sql
SELECT REPLACEALL(full_name, " ", "_") as updated_name
FROM employees;
The above query will give the following output:
+-+
updated_name
+-+
John_Doe
Jane_Smith
Michael_Johnson
Sarah_Williams
+-+
As you can see, the `REPLACEALL` function has replaced all the spaces with underscores in the `full_name` column.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论