[fix](Nereids) type coercion on case-when is not correct (#12650)
When we do type coercion on CaseWhen expression, such as sql like this: ``` CASE WHEN n_nationkey > 1 THEN n_regionkey ELSE 0 END ``` The ELSE part 0 need do type coercion as CAST (0 AS INT). But we miss it in PR #11802
This commit is contained in:
@ -65,7 +65,11 @@ public class CaseWhen extends Expression {
|
||||
}
|
||||
|
||||
public List<DataType> dataTypesForCoercion() {
|
||||
return whenClauses.stream().map(WhenClause::getDataType).collect(Collectors.toList());
|
||||
List<DataType> result = whenClauses.stream().map(WhenClause::getDataType).collect(Collectors.toList());
|
||||
if (defaultValue.isPresent()) {
|
||||
result.add(defaultValue.get().getDataType());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
|
||||
Reference in New Issue
Block a user