You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Gabriel39 (via GitHub)" <gi...@apache.org> on 2023/07/04 02:56:28 UTC
[GitHub] [doris] Gabriel39 commented on a diff in pull request #21371: [feature](datetime) "timediff" supports calculating microseconds
Gabriel39 commented on code in PR #21371:
URL: https://github.com/apache/doris/pull/21371#discussion_r1251416094
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/TimeV2Type.java:
##########
@@ -28,13 +29,26 @@ public class TimeV2Type extends PrimitiveType {
public static final TimeV2Type INSTANCE = new TimeV2Type();
private static final int WIDTH = 8;
+ private final int scale;
+
+ private TimeV2Type(int scale) {
+ this.scale = scale;
+ }
private TimeV2Type() {
+ scale = 6;
Review Comment:
Why is 6?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/TimeDiff.java:
##########
@@ -46,8 +48,7 @@ public class TimeDiff extends ScalarFunction
FunctionSignature.ret(TimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
- FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE)
- );
+ FunctionSignature.ret(TimeType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE));
Review Comment:
```suggestion
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE));
```
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java:
##########
@@ -1559,6 +1559,13 @@ && collectChildReturnTypes()[0].isDecimalV3()) {
}
if (fn.getFunctionName().getFunction().equals("timediff")) {
fn.getReturnType().getPrimitiveType().setTimeType();
+ ScalarType left = (ScalarType) argTypes[0];
+ ScalarType rigth = (ScalarType) argTypes[1];
+ if (left.isDatetimeV2() || rigth.isDatetimeV2()) {
Review Comment:
also for datev2
##########
fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java:
##########
@@ -432,7 +434,7 @@ public static ScalarType createTimeType() {
if (!Config.enable_date_conversion) {
return new ScalarType(PrimitiveType.TIME);
}
- ScalarType type = new ScalarType(PrimitiveType.TIMEV2);
+ ScalarType type = new ScalarType(PrimitiveType.TIME);
Review Comment:
Why make this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org