From 95bc6ba0ca5056274ccc81608919de22032084ad Mon Sep 17 00:00:00 2001 From: Arttu Date: Wed, 3 Jul 2024 19:49:38 +0200 Subject: [PATCH] feat: add "initcap" function (#656) Initcap is like "[title](https://github.com/Blizzara/substrait/blob/70d1eb71623ca0754157dd5d87348bae51d420c4/extensions/functions_string.yaml#L1023)", but while "title" defines articles are not to be capitalized, initcap capitalizes also articles. Initcap is supported by basically all DB systems, including Spark and DataFusion --- extensions/functions_string.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/extensions/functions_string.yaml b/extensions/functions_string.yaml index 2e0f174db..3acdb48ae 100644 --- a/extensions/functions_string.yaml +++ b/extensions/functions_string.yaml @@ -1048,6 +1048,34 @@ scalar_functions: char_set: values: [ UTF8, ASCII_ONLY ] return: "fixedchar" + - + name: initcap + description: >- + Capitalizes the first character of each word in the input string, including articles, + and lowercases the rest. Implementation should follow the utf8_unicode_ci collations + according to the Unicode Collation Algorithm described at http://www.unicode.org/reports/tr10/. + impls: + - args: + - value: "string" + name: "input" + options: + char_set: + values: [ UTF8, ASCII_ONLY ] + return: "string" + - args: + - value: "varchar" + name: "input" + options: + char_set: + values: [ UTF8, ASCII_ONLY ] + return: "varchar" + - args: + - value: "fixedchar" + name: "input" + options: + char_set: + values: [ UTF8, ASCII_ONLY ] + return: "fixedchar" - name: char_length description: >-