You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: Optimize trim UDFs for single-character trims (#20328)
## Which issue does this PR close?
- Closes#20327
## Rationale for this change
By default, btrim(), ltrim(), and rtrim() trim space characters; it is
also reasonably common for queries to specify a non-default trim pattern
that is still a single ASCII character.
We can optimize for this case by doing a byte-level scan, rather than
invoking the more heavyweight std::string machinery used for more
complex trim scenarios.
## What changes are included in this PR?
Add a benchmark for trimming spaces, and implement the optimization
described above. Also fixed an error in the documentation.
## Are these changes tested?
Yes, and benchmarked.
## Are there any user-facing changes?
No.
---------
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
description = "Trims the specified trim string from the start and end of a string. If no trim string is provided, all whitespace is removed from the start and end of the input string.",
48
+
description = "Trims the specified trim string from the start and end of a string. If no trim string is provided, all spaces are removed from the start and end of the input string.",
description = r"String expression to operate on. Can be a constant, column, or function, and any combination of operators. _Default is whitespace characters._"
61
+
description = r"String expression to operate on. Can be a constant, column, or function, and any combination of operators. _Default is a space._"
62
62
),
63
63
alternative_syntax = "trim(BOTH trim_str FROM str)",
description = "Trims the specified trim string from the beginning of a string. If no trim string is provided, all whitespace is removed from the start of the input string.",
49
+
description = "Trims the specified trim string from the beginning of a string. If no trim string is provided, spaces are removed from the start of the input string.",
description = r"String expression to trim from the beginning of the input string. Can be a constant, column, or function, and any combination of arithmetic operators. _Default is whitespace characters._"
68
+
description = r"String expression to trim from the beginning of the input string. Can be a constant, column, or function, and any combination of arithmetic operators. _Default is a space._"
69
69
),
70
70
alternative_syntax = "trim(LEADING trim_str FROM str)",
0 commit comments