Commit f8fb5bd
authored
fix: Avoid unnecessary type casts in
## Which issue does this PR close?
- Closes apache#20434.
## Rationale for this change
1. `concat_ws` returned `Utf8`, regardless of the input types it was
called with. If it was called with `LargeUtf8`, returning `Utf8` might
overflow. In general, functions like these should operate on all three
string representations unless there is a compelling reason not to (e.g.,
this is how `concat` works).
4. `simplify_concat_ws` always constructed new literals with type
`Utf8`. This lead to unnecessary casts when its inputs were of a
different string type.
## What changes are included in this PR?
* Support `concat_ws` return type matching its input types, following
how `concat` does it.
* In `simplify_concat_ws`, construct literals with the right type, not
always `Utf8`
* Refactor `return_type` for `concat` to be more readable
* Make `StringViewArrayBuilder` API more similar to the other string
array builders, WRT null handling
* Add new unit and SLT tests
* Update test output for changed types
## Are these changes tested?
Yes.
## Are there any user-facing changes?
Yes: some queries involving `concat_ws` will now omit unnecessary cast
operations, and the return type of `concat_ws` might be any of the three
string types. Generally these changes should match user expectations
better than the previous behavior.concat_ws (apache#20436)1 parent d68b800 commit f8fb5bd
File tree
4 files changed
+380
-68
lines changed- datafusion
- functions/src
- string
- sqllogictest/test_files/string
4 files changed
+380
-68
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
122 | 118 | | |
123 | 119 | | |
124 | 120 | | |
| |||
247 | 243 | | |
248 | 244 | | |
249 | 245 | | |
250 | | - | |
| 246 | + | |
251 | 247 | | |
252 | 248 | | |
253 | 249 | | |
| |||
0 commit comments