feat(new-functions): migrate lower() to new expression framework
@@ -39,5 +39,27 @@ pub fn register(registry: &mut FunctionRegistry) {
Ok(())
},
);
+ registry.register_with_writer_1_arg::<StringType, StringType, _, _>(
+ "lower",
+ FunctionProperty::default(),
+ |_| None,
+ |val, writer| {
+ for (start, end, ch) in val.char_indices() {
+ if ch == '\u{FFFD}' {
+ // If char is invalid, just copy it.
+ writer.put_slice(&val.as_bytes()[start..end]);
+ } else if ch.is_ascii() {
+ writer.put_u8(ch.to_ascii_lowercase() as u8);
+ } else {
+ for x in ch.to_lowercase() {
+ writer.put_char(x);
+ }
+ }
+ }
+ writer.commit_row();
+ Ok(())
+ },
+ );
registry.register_aliases("upper", &["ucase"]);
+ registry.register_aliases("lower", &["lcase"]);
}
