Simplify concat_ws(null, ..) to null#3608
Conversation
Signed-off-by: remzi <13716567376yh@gmail.com>
Signed-off-by: remzi <13716567376yh@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #3608 +/- ##
==========================================
+ Coverage 86.06% 86.07% +0.01%
==========================================
Files 300 300
Lines 56328 56337 +9
==========================================
+ Hits 48479 48493 +14
+ Misses 7849 7844 -5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
alamb
left a comment
There was a problem hiding this comment.
Thank you @HaoYang670 -- this change makes sense to me and I think it could be merged as is. However, I think it is worth considering handling nulls in positions other than the first as well
| out_expr.rewrite(self)? | ||
| } | ||
|
|
||
| // concat_ws |
There was a problem hiding this comment.
| // concat_ws | |
| // concat_ws | |
| // If any of the arguments is NULL, the output will be null |
@alamb, if the separator is If These is the behavior in Datafusion and Postgresql: https://pgpedia.info/c/concat_ws.html#:~:text=concat_ws%20%28%29%20is%20a%20system%20function%20for%20concatenating,%20%20val2%20any%20%5B%2C...%5D%20%5D%29%20%E2%86%92%20text So we should only check |
Perhaps we can add a test for that behavior explicitly (as in a test that a null at the second position does not result in a rewrite) to make it clear that is the expected behavior |
|
Will add. |
|
In case anyone else is interested in how ❯ select concat_ws('--', 'foo', 'bar', 'baz');
+---------------------------------------------------------------------+
| concatwithseparator(Utf8("--"),Utf8("foo"),Utf8("bar"),Utf8("baz")) |
+---------------------------------------------------------------------+
| foo--bar--baz |
+---------------------------------------------------------------------+
1 row in set. Query took 0.000 seconds.
❯ select concat_ws('--', null, 'bar', 'baz');
+--------------------------------------------------------------+
| concatwithseparator(Utf8("--"),NULL,Utf8("bar"),Utf8("baz")) |
+--------------------------------------------------------------+
| bar--baz |
+--------------------------------------------------------------+
1 row in set. Query took 0.003 seconds.
❯ select concat_ws(null, 'foo', 'bar', 'baz');
+---------------------------------------------------------------+
| concatwithseparator(NULL,Utf8("foo"),Utf8("bar"),Utf8("baz")) |
+---------------------------------------------------------------+
| |
+---------------------------------------------------------------+
1 row in set. Query took 0.000 seconds. |
Signed-off-by: remzi <13716567376yh@gmail.com>
alamb
left a comment
There was a problem hiding this comment.
LGTM -- thanks @HaoYang670
|
Benchmark runs are scheduled for baseline = ebb28f5 and contender = c8a9ea0. c8a9ea0 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Signed-off-by: remzi 13716567376yh@gmail.com
Which issue does this PR close?
Closes #3607.
Rationale for this change
Before the optimization
After the optimization
What changes are included in this PR?
Are there any user-facing changes?