[Fix](Nereids) fix nereids fold failed by be return null exception (#19013)

```sql
select if(
    date_format(CONCAT_WS('', '9999-07', '-26'), '%Y-%m') = DATE_FORMAT(curdate(), '%Y-%m'),
    curdate(),
    DATE_FORMAT(DATE_SUB(month_ceil(CONCAT_WS('', '9999-07', '-26')), 1), '%Y-%m-%d')
) 
```
return null when construct new children of if(), we find that the the more than "0" index in result map doesn't replace the const map caused by incorrect value-assignment in code.
This commit is contained in:
mch_ucchi
2023-04-26 14:57:45 +08:00
committed by GitHub
parent 39cf393874
commit 6356146274
4 changed files with 81 additions and 2 deletions

View File

@ -192,9 +192,9 @@ public class FoldConstantRuleOnBE extends AbstractExpressionRewriteRule {
DataType t1 = DataType.convertFromString(staleExpr.getType().getPrimitiveType().toString());
ret = Literal.of(staleExpr.getStringValue()).castTo(t1);
} else {
ret = constMap.get(e.getKey());
ret = constMap.get(e1.getKey());
}
resultMap.put(e.getKey(), ret);
resultMap.put(e1.getKey(), ret);
}
}