[Bug](datev2) Fix wrong cast expr (#15985)
Found by regression tests when I turn on enable_date_conversion
This commit is contained in:
@ -21,7 +21,6 @@
|
||||
package org.apache.doris.analysis;
|
||||
|
||||
import org.apache.doris.catalog.PrimitiveType;
|
||||
import org.apache.doris.catalog.ScalarType;
|
||||
import org.apache.doris.catalog.Type;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.DdlException;
|
||||
@ -185,8 +184,8 @@ public class StringLiteral extends LiteralExpr {
|
||||
newLiteral = new DateLiteral(value, targetType);
|
||||
} catch (AnalysisException e) {
|
||||
if (targetType.isScalarType(PrimitiveType.DATETIME)) {
|
||||
newLiteral = new DateLiteral(value, ScalarType.getDefaultDateType(Type.DATE));
|
||||
newLiteral.setType(ScalarType.getDefaultDateType(Type.DATETIME));
|
||||
newLiteral = new DateLiteral(value, Type.DATE);
|
||||
newLiteral.setType(Type.DATETIME);
|
||||
} else if (targetType.isScalarType(PrimitiveType.DATETIMEV2)) {
|
||||
newLiteral = new DateLiteral(value, Type.DATEV2);
|
||||
newLiteral.setType(targetType);
|
||||
|
||||
@ -285,11 +285,8 @@ public class TimestampArithmeticExpr extends Expr {
|
||||
for (int i = 0; i < childrenTypes.length; ++i) {
|
||||
// For varargs, we must compare with the last type in callArgs.argTypes.
|
||||
int ix = Math.min(argTypes.length - 1, i);
|
||||
if (!childrenTypes[i].matchesType(argTypes[ix]) && Config.enable_date_conversion
|
||||
&& !childrenTypes[i].isDateType() && (argTypes[ix].isDate() || argTypes[ix].isDatetime())) {
|
||||
uncheckedCastChild(ScalarType.getDefaultDateType(argTypes[ix]), i);
|
||||
} else if (!childrenTypes[i].matchesType(argTypes[ix]) && !(
|
||||
childrenTypes[i].isDateType() && argTypes[ix].isDateType())) {
|
||||
if (!childrenTypes[i].matchesType(argTypes[ix]) && !(
|
||||
childrenTypes[i].isDateOrDateTime() && argTypes[ix].isDateOrDateTime())) {
|
||||
uncheckedCastChild(argTypes[ix], i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user