This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 98dad6158b [fix](Nereids) type coercion on case-when is not correct
(#12650)
98dad6158b is described below
commit 98dad6158b306517c9341f9ebcab2e07e698dc41
Author: minghong <[email protected]>
AuthorDate: Fri Sep 16 02:26:11 2022 +0800
[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
---
.../java/org/apache/doris/nereids/trees/expressions/CaseWhen.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CaseWhen.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CaseWhen.java
index deed64941b..94015ec5ff 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CaseWhen.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CaseWhen.java
@@ -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) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]