github-actions[bot] commented on code in PR #62905:
URL: https://github.com/apache/doris/pull/62905#discussion_r3216956893
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java:
##########
@@ -476,10 +477,27 @@ public static Expression castIfNotSameType(Expression
input, DataType targetType
}
}
+ /**
+ * Wrap {@code expression} in a cast to {@code targetType} when the source
type can
+ * already be resolved (Literal, or any expression whose {@code
getDataType()} does
+ * not throw {@link UnboundException}). For Literals, defers to
+ * {@link #castIfNotSameType}; for other resolvable expressions, validates
the cast
+ * via {@link #checkCanCastTo} before constructing it. Used by INSERT
VALUES so that
+ * illegal casts (e.g. {@code variant<config_A>} → {@code
variant<config_B>}) are
+ * rejected at parse time instead of slipping past analysis and crashing
BE.
+ * Truly unbound expressions are wrapped without validation; the normal
analysis
+ * pipeline's CheckCast pass will validate them after binding.
+ */
public static Expression castUnbound(Expression expression, DataType
targetType) {
if (expression instanceof Literal) {
return TypeCoercionUtils.castIfNotSameType(expression, targetType);
} else {
+ try {
+ checkCanCastTo(expression.getDataType(), targetType);
Review Comment:
This validation still lets some mismatched Variant-to-Variant casts through
because `checkCanCastTo` calls `CheckCast.check`, and the Variant-to-Variant
branch there only does `originalType.equals(targetType)`. `VariantType.equals`
currently compares `variantMaxSubcolumnsCount`, `enableTypedPathsToSparse`,
`enableVariantDocMode`, `variantDocMaterializationMinRows`, and fields, but it
ignores writer-relevant properties such as `variantDocShardCount`,
`variantSparseHashShardCount`, `variantMaxSparseColumnStatisticsSize`, and
`enableNestedGroup` (while `hashCode` includes most of them). A source like
`cast(... as variant<properties("variant_enable_doc_mode"="true",
"variant_doc_materialization_min_rows"="8",
"variant_doc_hash_shard_count"="999")>)` inserted into the test table with doc
hash shard count 7 will therefore pass this new FE check even though the PR
states BE has no real Variant-to-Variant conversion for mismatched configs.
Please make the Variant-to-Variant compatibility
check compare all persisted/writer-affecting Variant properties, and add
regression coverage for at least one of the currently ignored properties.
--
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]