[fix](nereids) to_date should return type datev2 for datetimev2 (#21375)

To_date function in nereids return type should be DATEV2 if the arg type is DATETIMEV2.
Before the return type was DATE which would cause BE get wrong query result.
This commit is contained in:
Jibing-Li
2023-06-30 21:42:59 +08:00
committed by GitHub
parent 18b7d84436
commit ed2cd4974e
3 changed files with 76 additions and 2 deletions

View File

@ -522,9 +522,9 @@ public class DateTimeExtractAndTransform {
return new DateLiteral(date.getYear(), date.getMonth(), date.getDay());
}
@ExecFunction(name = "to_date", argTypes = {"DATETIMEV2"}, returnType = "DATE")
@ExecFunction(name = "to_date", argTypes = {"DATETIMEV2"}, returnType = "DATEV2")
public static Expression toDate(DateTimeV2Literal date) {
return new DateLiteral(date.getYear(), date.getMonth(), date.getDay());
return new DateV2Literal(date.getYear(), date.getMonth(), date.getDay());
}
/**