[fix](nereids) cast left child of TimestampArithmetic to wrong type in BindFunction (#12423)

This commit is contained in:
Kikyou1997
2022-09-07 20:32:47 +08:00
committed by GitHub
parent c2808de867
commit bdbce77227
2 changed files with 2 additions and 1 deletions

View File

@ -175,7 +175,7 @@ public class BindFunction implements AnalysisRuleFactory {
} catch (Exception e) {
// ignore
}
if (!left.getDataType().isDateType() && arithmetic.getTimeUnit().isDateTimeUnit()) {
if (!left.getDataType().isDateType() && !arithmetic.getTimeUnit().isDateTimeUnit()) {
left = arithmetic.left().castTo(DateType.INSTANCE);
}
}

View File

@ -36,6 +36,7 @@ import java.util.List;
* Describes the addition and subtraction of time units from timestamps.
* Arithmetic expressions on timestamps are syntactic sugar.
* They are executed as function call exprs in the BE.
* Example: '1996-01-01' + INTERVAL '3' month;
* TODO: we need to rethink this, and maybe need to add a new type of Interval then implement IntervalLiteral as others
*/
public class TimestampArithmetic extends Expression implements BinaryExpression {