github-actions[bot] commented on code in PR #69025:
URL: https://github.com/apache/doris/pull/69025#discussion_r4282022093


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAfterRewrite.java:
##########
@@ -192,20 +193,27 @@ private void checkMetricTypeIsUsedCorrectly(Plan plan) {
         } else if (plan instanceof LogicalJoin) {
             LogicalJoin<?, ?> join = (LogicalJoin<?, ?>) plan;
             for (Expression conjunct : join.getHashJoinConjuncts()) {
-                if (conjunct.anyMatch(e -> ((Expression) 
e).getDataType().isVarBinaryType())) {
+                if (comparesVarBinary(conjunct)) {
                     throw new AnalysisException(
                             "varbinary type could not in join equal 
conditions: " + conjunct.toSql());
                 }
             }
             for (Expression conjunct : join.getMarkJoinConjuncts()) {
-                if (conjunct.anyMatch(e -> ((Expression) 
e).getDataType().isVarBinaryType())) {
+                if (comparesVarBinary(conjunct)) {
                     throw new AnalysisException(
                             "varbinary type could not in join equal 
conditions: " + conjunct.toSql());
                 }
             }
         }
     }
 
+    // BE cannot hash or compare VARBINARY values, but a join condition may 
compare strings cast from VARBINARY,
+    // such as CAST(X'FF' AS STRING) = s, so only the compared operands are 
checked.
+    private static boolean comparesVarBinary(Expression conjunct) {
+        return conjunct.anyMatch(e -> e instanceof ComparisonPredicate && 
((ComparisonPredicate) e).children()

Review Comment:
   [P1] Reject nested VARBINARY keys before shuffle hashing: 
`comparesVarBinary` checks only each comparison operand's immediate type, so 
`ARRAY<VARBINARY>` equality passes the post-rewrite check and is extracted as a 
hash conjunct. In a partitioned join, the exchange invokes 
`Crc32HashPartitioner::_do_hash`/`Crc32CHashPartitioner::_do_hash`; 
`ColumnArray` recursively calls `update_crcs_with_value`/`update_crc32c_batch` 
on its nested `ColumnVarbinary`, whose hash methods intentionally throw 
`NOT_IMPLEMENTED_ERROR`. The serialized in-node hash path runs only after this 
exchange, so a forced-shuffle join on two array-of-binary keys fails before the 
join executes. Check the operand type recursively (for example with 
`TypeCoercionUtils.hasVarBinaryType(operand.getDataType())`) or add compatible 
nested-binary exchange hashing, and add a forced-shuffle `ARRAY<VARBINARY>` 
regression.



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