IMPALA-5326: [DOCS] Document REPLACE() function Included syntax, mention of performance benefit, and examples. Also added an item in the "new features" list with a link to the detailed writeup.
Change-Id: Ib576fba03673bd6708a46f45c8388477b25e34da Reviewed-on: http://gerrit.cloudera.org:8080/6979 Reviewed-by: Greg Rahn <[email protected]> Reviewed-by: Michael Brown <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/f2580acb Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/f2580acb Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/f2580acb Branch: refs/heads/master Commit: f2580acba5201628592742b1bda5f49614d1400f Parents: 64e8538 Author: John Russell <[email protected]> Authored: Wed May 24 12:23:33 2017 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Thu Jun 1 17:12:27 2017 +0000 ---------------------------------------------------------------------- docs/topics/impala_new_features.xml | 11 +++++- docs/topics/impala_string_functions.xml | 58 ++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/f2580acb/docs/topics/impala_new_features.xml ---------------------------------------------------------------------- diff --git a/docs/topics/impala_new_features.xml b/docs/topics/impala_new_features.xml index 76f772d..e6f2afa 100644 --- a/docs/topics/impala_new_features.xml +++ b/docs/topics/impala_new_features.xml @@ -60,12 +60,19 @@ under the License. <xref keyref="changelog_29">changelog for <keyword keyref="impala29"/></xref>. </p> -<!-- Prose explanations of most important new features - TBD. + <p> + The following are some of the most significant new features in this release: + </p> + <ul id="feature_list"> <li> + <p rev="IMPALA-4729"> + A new function, <codeph>replace()</codeph>, which is faster than + <codeph>regexp_replace()</codeph> for simple string substitutions. + See <xref keyref="string_functions"/> for details. + </p> </li> </ul> ---> </conbody> </concept> http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/f2580acb/docs/topics/impala_string_functions.xml ---------------------------------------------------------------------- diff --git a/docs/topics/impala_string_functions.xml b/docs/topics/impala_string_functions.xml index 11a1673..60b28fc 100644 --- a/docs/topics/impala_string_functions.xml +++ b/docs/topics/impala_string_functions.xml @@ -845,6 +845,64 @@ Returned 1 row(s) in 0.12s</codeblock> </dlentry> + <dlentry id="replace" rev="2.9.0 IMPALA-4729"> + + <dt> + <codeph>replace(string initial, string target, string replacement)</codeph> + </dt> + + <dd> + <indexterm audience="hidden">replace() function</indexterm> + <b>Purpose:</b> Returns the initial argument with all occurrences of the target string + replaced by the replacement string. + <p> + <b>Return type:</b> <codeph>string</codeph> + </p> + <p conref="../shared/impala_common.xml#common/usage_notes_blurb"/> + <p> + Because this function does not use any regular expression patterns, it is typically faster + than <codeph>regexp_replace()</codeph> for simple string substitutions. + </p> + <p> + If any argument is <codeph>NULL</codeph>, the return value is <codeph>NULL</codeph>. + </p> + <p> + Matching is case-sensitive. + </p> + <p> + If the replacement string contains another instance of the target + string, the expansion is only performed once, instead of + applying again to the newly constructed string. + </p> + <p conref="../shared/impala_common.xml#common/example_blurb"/> +<codeblock>-- Replace one string with another. +select replace('hello world','world','earth'); ++------------------------------------------+ +| replace('hello world', 'world', 'earth') | ++------------------------------------------+ +| hello earth | ++------------------------------------------+ + +-- All occurrences of the target string are replaced. +select replace('hello world','o','0'); ++----------------------------------+ +| replace('hello world', 'o', '0') | ++----------------------------------+ +| hell0 w0rld | ++----------------------------------+ + +-- If no match is found, the original string is returned unchanged. +select replace('hello world','xyz','abc'); ++--------------------------------------+ +| replace('hello world', 'xyz', 'abc') | ++--------------------------------------+ +| hello world | ++--------------------------------------+ +</codeblock> + </dd> + + </dlentry> + <dlentry id="reverse"> <dt>
