zclllyybb commented on code in PR #26827:
URL: https://github.com/apache/doris/pull/26827#discussion_r1402105007


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java:
##########
@@ -412,6 +412,11 @@ private static Expression unSafeCast(Expression input, 
DataType dataType) {
                     return promoted;
                 }
             }
+            // adapt scale when from string to datetimev2 with float
+            if (type.isStringLikeType() && dataType.isDateTimeV2Type()) {
+                return recordTypeCoercionForSubQuery(input,
+                        DateTimeV2Type.forTypeFromString(((Literal) 
input).getStringValue()));

Review Comment:
   In my opinion, casting a string literal to datetime literal is always 
correct if the casting doesn't lose any information. 
   If we have to compare a literal with a column, there's two probability:
   1. they could compare directly, like `datetimev2(3)` and `datetimev2(6)`. It 
doesn't matter.
   2. they couldn't compare directly, like `datetimev2(3)` and `varchar`. then 
we must do a new cast between at least one of them.
   
   No matter which one, the second step of conversion(if have) for comparing 
has nothing to do with the conversion from string to datelike type which 
doesn't lose information. what you concerned about should be done in the step 
2. I'll add some regression-test to prove and ensure this.



-- 
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-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to