Skip to content

Commit 41a3722

Browse files
committed
[fix][runtime] The concat function supports composite types
1 parent 96bade7 commit 41a3722

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

runtime/src/main/java/io/dingodb/expr/runtime/op/string/ConcatFun.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@
1919
import io.dingodb.expr.common.type.Type;
2020
import io.dingodb.expr.common.type.Types;
2121
import io.dingodb.expr.runtime.ExprConfig;
22-
import io.dingodb.expr.runtime.op.BinaryOp;
2322
import io.dingodb.expr.runtime.op.OpKey;
23+
import io.dingodb.expr.runtime.op.OpKeys;
2424
import io.dingodb.expr.runtime.op.VariadicOp;
2525
import org.checkerframework.checker.nullness.qual.NonNull;
2626

27+
import java.io.Serial;
28+
2729
public class ConcatFun extends VariadicOp {
28-
public static final String NAME = "CONCAT";
2930
public static final ConcatFun INSTANCE = new ConcatFun();
3031

31-
private static final long serialVersionUID = 5454356467741754567L;
32+
public static final String NAME = "CONCAT";
3233

33-
//@Override
34-
public Object evalValue(Object value0, Object value1, ExprConfig config) {
35-
if (value0 == null || value1 == null) {
36-
return null;
37-
}
38-
return String.valueOf(value0) + value1;
39-
}
34+
@Serial
35+
private static final long serialVersionUID = -6456730710140240892L;
4036

4137
@Override
42-
protected Object evalNonNullValue(@NonNull Object[] value, ExprConfig config) {
38+
public Object evalValue(Object @NonNull [] values, ExprConfig config) {
4339
StringBuilder stringBuilder = new StringBuilder();
44-
for (Object valueItem : value) {
45-
stringBuilder.append(valueItem);
40+
for (Object value : values) {
41+
if (value == null) {
42+
return null;
43+
} else {
44+
stringBuilder.append(value);
45+
}
4646
}
4747
return stringBuilder.toString();
4848
}
@@ -53,12 +53,12 @@ protected Object evalNonNullValue(@NonNull Object[] value, ExprConfig config) {
5353
}
5454

5555
@Override
56-
public Type getType() {
57-
return Types.STRING;
56+
public OpKey keyOf(@NonNull Type @NonNull ... types) {
57+
return OpKeys.ALL_STRING.keyOf(types);
5858
}
5959

6060
@Override
61-
public OpKey keyOf(@NonNull Type @NonNull ... types) {
62-
return null;
61+
public Type getType() {
62+
return Types.STRING;
6363
}
6464
}

0 commit comments

Comments
 (0)