github-actions[bot] commented on code in PR #64080:
URL: https://github.com/apache/doris/pull/64080#discussion_r3355740218
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/ArrayType.java:
##########
@@ -57,6 +58,14 @@ public DataType getItemType() {
return itemType;
}
+ @Override
+ public boolean canSafetyCastTo(DataType target) {
+ if (target instanceof ArrayType) {
+ return itemType.canSafetyCastTo(((ArrayType) target).itemType);
+ }
Review Comment:
`canSafetyCastTo` is now used to decide whether `UNION DISTINCT` duplicate
elimination may be moved after the cast, so `true` here must mean the cast is
injective. Complex-to-character casts are not always injective: for
arrays/maps/structs containing `FLOAT` or `DOUBLE`, direct
float/double-to-string is intentionally not marked safe, but complex
stringification delegates to the nested serde (for arrays,
`DataTypeArraySerDe::to_string` calls `nested_serde->to_string`) and BE formats
float/double with only `digits10 + 1` significant digits in `cast_to_string.h`.
Two distinct arrays whose float elements differ only beyond that formatted
precision can therefore stringify to the same value; after this rewrite the
pushed cast would make `UNION DISTINCT` collapse a row that the original plan
kept. The same unconditional `target instanceof CharacterType` pattern in
`MapType` and `StructType` has the same issue. Please either leave
complex-to-character casts unsafe or require the nested t
ypes themselves to be injective when cast to the character target.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]