-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into zvonand-issue-49290
- Loading branch information
Showing
24 changed files
with
282 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <Functions/FunctionFactory.h> | ||
#include <Functions/FunctionStringToString.h> | ||
#include <Common/StringUtils/StringUtils.h> | ||
|
||
namespace DB | ||
{ | ||
namespace | ||
{ | ||
|
||
struct InitcapImpl | ||
{ | ||
static void vector(const ColumnString::Chars & data, | ||
const ColumnString::Offsets & offsets, | ||
ColumnString::Chars & res_data, | ||
ColumnString::Offsets & res_offsets) | ||
{ | ||
if (data.empty()) | ||
return; | ||
res_data.resize(data.size()); | ||
res_offsets.assign(offsets); | ||
array(data.data(), data.data() + data.size(), res_data.data()); | ||
} | ||
|
||
static void vectorFixed(const ColumnString::Chars & data, size_t /*n*/, ColumnString::Chars & res_data) | ||
{ | ||
res_data.resize(data.size()); | ||
array(data.data(), data.data() + data.size(), res_data.data()); | ||
} | ||
|
||
private: | ||
static void array(const UInt8 * src, const UInt8 * src_end, UInt8 * dst) | ||
{ | ||
bool prev_alphanum = false; | ||
|
||
for (; src < src_end; ++src, ++dst) | ||
{ | ||
char c = *src; | ||
bool alphanum = isAlphaNumericASCII(c); | ||
if (alphanum && !prev_alphanum) | ||
if (isAlphaASCII(c)) | ||
*dst = toUpperIfAlphaASCII(c); | ||
else | ||
*dst = c; | ||
else if (isAlphaASCII(c)) | ||
*dst = toLowerIfAlphaASCII(c); | ||
else | ||
*dst = c; | ||
prev_alphanum = alphanum; | ||
} | ||
} | ||
}; | ||
|
||
struct NameInitcap | ||
{ | ||
static constexpr auto name = "initcap"; | ||
}; | ||
using FunctionInitcap = FunctionStringToString<InitcapImpl, NameInitcap>; | ||
|
||
} | ||
|
||
REGISTER_FUNCTION(Initcap) | ||
{ | ||
factory.registerFunction<FunctionInitcap>({}, FunctionFactory::CaseInsensitive); | ||
} | ||
|
||
} |
Oops, something went wrong.