This is an automated email from the ASF dual-hosted git repository.
dzamo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new 520c68c78e DRILL-8222: Fix wrong func impl of concat_delim, when
null-value exist in middle args (#2546)
520c68c78e is described below
commit 520c68c78efb89c6a75f5888ff4e4f5a0f16695f
Author: xurenhe <[email protected]>
AuthorDate: Wed May 11 21:16:11 2022 +0800
DRILL-8222: Fix wrong func impl of concat_delim, when null-value exist in
middle args (#2546)
---
.../drill/exec/fn/impl/TestVarArgFunctions.java | 10 ++++++++++
.../exec/fn/impl/testing/VarCharConcatFunctions.java | 20 ++++++++++----------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git
a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestVarArgFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestVarArgFunctions.java
index 1004cd076e..fae6bdb96e 100644
---
a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestVarArgFunctions.java
+++
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestVarArgFunctions.java
@@ -96,6 +96,16 @@ public class TestVarArgFunctions extends ClusterTest {
.go();
}
+ @Test
+ public void testConcatDelimVarArgsWithNullValue() throws Exception {
+ testBuilder()
+ .sqlQuery("select concat_delim(',', 'a', null, 'b') as c")
+ .unOrdered()
+ .baselineColumns("c")
+ .baselineValues("a,b")
+ .go();
+ }
+
@Test
public void testVarargUdfWithDifferentDataModes() throws Exception {
testBuilder()
diff --git
a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/VarCharConcatFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/VarCharConcatFunctions.java
index 22402eb145..dd78a7358a 100644
---
a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/VarCharConcatFunctions.java
+++
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/VarCharConcatFunctions.java
@@ -165,12 +165,12 @@ public class VarCharConcatFunctions {
boolean addSeparator = false;
for (NullableVarCharHolder input : inputs) {
- if (addSeparator) {
- for (int id = separator.start; id < separator.end; id++) {
- out.buffer.setByte(out.end++, separator.buffer.getByte(id));
- }
- }
if (input.isSet > 0) {
+ if (addSeparator) {
+ for (int id = separator.start; id < separator.end; id++) {
+ out.buffer.setByte(out.end++, separator.buffer.getByte(id));
+ }
+ }
addSeparator = true;
for (int id = input.start; id < input.end; id++) {
out.buffer.setByte(out.end++, input.buffer.getByte(id));
@@ -258,12 +258,12 @@ public class VarCharConcatFunctions {
boolean addSeparator = false;
for (NullableVarCharHolder input : inputs) {
- if (addSeparator) {
- for (int id = separator.start; id < separator.end; id++) {
- out.buffer.setByte(out.end++, separator.buffer.getByte(id));
- }
- }
if (input.isSet > 0) {
+ if (addSeparator) {
+ for (int id = separator.start; id < separator.end; id++) {
+ out.buffer.setByte(out.end++, separator.buffer.getByte(id));
+ }
+ }
addSeparator = true;
for (int id = input.start; id < input.end; id++) {
out.buffer.setByte(out.end++, input.buffer.getByte(id));