You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Murali Rao (JIRA)" <ji...@apache.org> on 2015/09/10 00:22:45 UTC
[jira] [Updated] (PIG-4673) Built In UDF - REPLACE_MULTI : For a
given string, search and replace all occurrences of search keys with
replacement values.
[ https://issues.apache.org/jira/browse/PIG-4673?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Murali Rao updated PIG-4673:
----------------------------
Description:
Lets say we have a string = 'ABCD'. Our objective is to replace A with 1, B with 2, C with 3 and D with 4 to derive 1234 string.
Using existing REPLACE method
REPLACE(REPLACE(REPLACE(REPLACE('ABCD','1'),'2'),'3'),'4')
With Proposed UDF : REPLACE_MULTI method
General Syntax :
REPLACE_MULTI(String sourceString,[search1#replacement1, ...])
REPLACE_MULTI('abcd',['A'#'1','B'#'2', 'C'#'3', 'D'#'4'])
Advantage :
1. Function calls are reduced.
2. Ease to code and better readable.
Let me know your thoughts/ inputs on having this UDF in Piggy Bank. Will take this up based on this.
was:
Lets say we have a string = 'ABCD'. Our objective is to replace A with 1, B with 2, C with 3 and D with 4 to derive 1234 string.
Using existing REPLACE method
REPLACE(REPLACE(REPLACE(REPLACE('ABCD','1'),'2'),'3'),'4')
With Proposed UDF : REPLACE_MULTI method
General Syntax :
MULTI_REPLACE(String sourceString,[search1#replacement1, ...])
REPLACE_MULTI('abcd',['A'#'1','B'#'2', 'C'#'3', 'D'#'4'])
Advantage :
1. Function calls are reduced.
2. Ease to code and better readable.
Let me know your thoughts/ inputs on having this UDF in Piggy Bank. Will take this up based on this.
> Built In UDF - REPLACE_MULTI : For a given string, search and replace all occurrences of search keys with replacement values.
> ------------------------------------------------------------------------------------------------------------------------------
>
> Key: PIG-4673
> URL: https://issues.apache.org/jira/browse/PIG-4673
> Project: Pig
> Issue Type: New Feature
> Components: piggybank
> Reporter: Murali Rao
> Assignee: Murali Rao
> Priority: Minor
>
> Lets say we have a string = 'ABCD'. Our objective is to replace A with 1, B with 2, C with 3 and D with 4 to derive 1234 string.
> Using existing REPLACE method
> REPLACE(REPLACE(REPLACE(REPLACE('ABCD','1'),'2'),'3'),'4')
> With Proposed UDF : REPLACE_MULTI method
> General Syntax :
> REPLACE_MULTI(String sourceString,[search1#replacement1, ...])
> REPLACE_MULTI('abcd',['A'#'1','B'#'2', 'C'#'3', 'D'#'4'])
> Advantage :
> 1. Function calls are reduced.
> 2. Ease to code and better readable.
>
> Let me know your thoughts/ inputs on having this UDF in Piggy Bank. Will take this up based on this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)