hello-stephen commented on code in PR #70408:
URL: https://github.com/apache/doris/pull/70408#discussion_r4731361418


##########
fe/fe-type/src/main/java/org/apache/doris/catalog/VariantType.java:
##########
@@ -224,18 +257,52 @@ public boolean supportSubType(Type subType) {
         return false;
     }
 
+    private int effectiveShardCount() {
+        if (enableNestedGroup) {
+            return 0;
+        }
+        return Math.max(1, enableVariantDocMode ? variantDocShardCount : 
variantSparseHashShardCount);
+    }
+
+    private int effectiveMaxSparseColumnStatisticsSize() {
+        if (enableNestedGroup || enableVariantDocMode) {
+            return 0;
+        }
+        return variantMaxSparseColumnStatisticsSize;
+    }
+
+    private TVariantSerializeType effectiveSerializeType() {
+        // the serialize type only changes what a max subcolumns count of 0 
means
+        return (variantMaxSubcolumnsCount != 0 || enableNestedGroup) ? null : 
variantSerializeType;
+    }
+
     @Override
     public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
         if (!(other instanceof VariantType)) {
             return false;
         }
         VariantType otherVariantType = (VariantType) other;
         return Objects.equals(otherVariantType.getPredefinedFields(), 
predefinedFields)
                 && variantMaxSubcolumnsCount == 
otherVariantType.variantMaxSubcolumnsCount
                 && enableTypedPathsToSparse == 
otherVariantType.enableTypedPathsToSparse
+                && effectiveMaxSparseColumnStatisticsSize()
+                        == 
otherVariantType.effectiveMaxSparseColumnStatisticsSize()
+                && effectiveShardCount() == 
otherVariantType.effectiveShardCount()
                 && enableVariantDocMode == 
otherVariantType.enableVariantDocMode
                 && variantDocMaterializationMinRows == 
otherVariantType.variantDocMaterializationMinRows
-                && enableNestedGroup == otherVariantType.enableNestedGroup;
+                && enableNestedGroup == otherVariantType.enableNestedGroup
+                && effectiveSerializeType() == 
otherVariantType.effectiveSerializeType();
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(), predefinedFields, 
variantMaxSubcolumnsCount,

Review Comment:
   [P2] Hash predefined catalog fields by value
   
   For a VARIANT with a nonempty template (e.g. `VARIANT<'x':INT>`), two calls 
to Nereids `VariantType.toCatalogDataType()` create distinct catalog 
`VariantField` instances. The resulting catalog types compare equal, but this 
list hash uses `VariantField`'s inherited identity hash, while its `equals()` 
compares pattern and type. Equal types can therefore have different hashes, so 
a `HashSet` containing the first can fail to find the second. Add a matching 
value-based `VariantField.hashCode()` (or hash its values here) and cover 
independently reconstructed nonempty templates; the new empty-template hash 
tests miss this case.



-- 
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]

Reply via email to