Skip to content

Commit b69fa67

Browse files
authored
Minor: Add documentation explaining that initcap oly works for ASCII (#13749)
1 parent 320e4d6 commit b69fa67

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

datafusion/functions/src/string/initcap.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,36 @@ fn get_initcap_doc() -> &'static Documentation {
9090
DOCUMENTATION.get_or_init(|| {
9191
Documentation::builder(
9292
DOC_SECTION_STRING,
93-
"Capitalizes the first character in each word in the input string. Words are delimited by non-alphanumeric characters.",
94-
"initcap(str)")
95-
.with_sql_example(r#"```sql
93+
"Capitalizes the first character in each word in the ASCII input string. \
94+
Words are delimited by non-alphanumeric characters.\n\n\
95+
Note this function does not support UTF-8 characters.",
96+
"initcap(str)",
97+
)
98+
.with_sql_example(
99+
r#"```sql
96100
> select initcap('apache datafusion');
97101
+------------------------------------+
98102
| initcap(Utf8("apache datafusion")) |
99103
+------------------------------------+
100104
| Apache Datafusion |
101105
+------------------------------------+
102-
```"#)
103-
.with_standard_argument("str", Some("String"))
104-
.with_related_udf("lower")
105-
.with_related_udf("upper")
106-
.build()
106+
```"#,
107+
)
108+
.with_standard_argument("str", Some("String"))
109+
.with_related_udf("lower")
110+
.with_related_udf("upper")
111+
.build()
107112
})
108113
}
109114

110-
/// Converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters.
115+
/// Converts the first letter of each word to upper case and the rest to lower
116+
/// case. Words are sequences of alphanumeric characters separated by
117+
/// non-alphanumeric characters.
118+
///
119+
/// Example:
120+
/// ```sql
111121
/// initcap('hi THOMAS') = 'Hi Thomas'
122+
/// ```
112123
fn initcap<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
113124
let string_array = as_generic_string_array::<T>(&args[0])?;
114125

docs/source/user-guide/sql/scalar_functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,9 @@ find_in_set(str, strlist)
10461046

10471047
### `initcap`
10481048

1049-
Capitalizes the first character in each word in the input string. Words are delimited by non-alphanumeric characters.
1049+
Capitalizes the first character in each word in the ASCII input string. Words are delimited by non-alphanumeric characters.
1050+
1051+
Note this function does not support UTF-8 characters.
10501052

10511053
```
10521054
initcap(str)

0 commit comments

Comments
 (0)