change as request

This commit is contained in:
taiyang-li 2024-08-19 18:25:01 +08:00
parent 8eb922036e
commit 29a0161cdf
2 changed files with 18 additions and 11 deletions

View File

@ -251,7 +251,8 @@ select printf('%%%s %s %d', 'Hello', 'World', 2024);
## overlay
Replace the string `s` with the string `replace` starting from the 1-based `offset` for `length` bytes. If `length` is omitted or negative, then it defaults to the length of `replace`.
Replace a part of a string `s` with another string `replace`, starting at 1-based index `offset`. By default, the number of bytes removed from `s` equals the length of `replace`. If `length` (the optional fourth argument) is specified, a different number of bytes is removed.
**Syntax**
@ -286,7 +287,7 @@ Result:
## overlayUTF8
Replace the string `s` with the string `replace` starting from the 1-based `offset` for `length` UTF-8 characters. If `length` is omitted or negative, then it defaults to the length of `replace`.
Replace a part of a string `s` with another string `replace`, starting at 1-based index `offset`. By default, the number of characters removed from `s` equals the length of `replace`. If `length` (the optional fourth argument) is specified, a different number of characters is removed.
Assumes that the string contains valid UTF-8 encoded text. If this assumption is violated, no exception is thrown and the result is undefined.

View File

@ -11,12 +11,6 @@
namespace DB
{
namespace ErrorCodes
{
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
namespace
{
@ -708,8 +702,20 @@ private:
REGISTER_FUNCTION(Overlay)
{
factory.registerFunction<FunctionOverlay<false>>({}, FunctionFactory::Case::Insensitive);
factory.registerFunction<FunctionOverlay<true>>({}, FunctionFactory::Case::Sensitive);
}
factory.registerFunction<FunctionOverlay<false>>(
{.description = R"(
Replace a part of a string `s` with another string `replace`, starting at 1-based index `offset`. By default, the number of bytes removed from `s` equals the length of `replace`. If `length` (the optional fourth argument) is specified, a different number of bytes is removed.
)",
.categories{"String"}},
FunctionFactory::Case::Insensitive);
factory.registerFunction<FunctionOverlay<true>>(
{.description = R"(
Replace a part of a string `s` with another string `replace`, starting at 1-based index `offset`. By default, the number of bytes removed from `s` equals the length of `replace`. If `length` (the optional fourth argument) is specified, a different number of bytes is removed.
Assumes that the string contains valid UTF-8 encoded text. If this assumption is violated, no exception is thrown and the result is undefined.
)",
.categories{"String"}},
FunctionFactory::Case::Sensitive);
}
}