924060929 commented on code in PR #68853:
URL: https://github.com/apache/doris/pull/68853#discussion_r4665433519


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java:
##########
@@ -182,6 +182,14 @@ private static boolean isUnsafeDateArithmetic(Expression 
expression) {
         return false;
     }
 
+    /** Reject FILE values in SQL keys that require comparison, ordering, or 
hashing. */
+    public static void checkFileKey(Expression value, String operation) {

Review Comment:
   I’d replace `checkFileKey(expr, operation)` with a check on the bound type, 
for example `DataType.allowsKeyUse(KeyUse)` with `ORDERING` and 
`GROUP_EQUALITY`. `FileType` would reject both uses. Arrays, maps and structs 
would check their element, key/value and field types respectively, and 
`AggStateType` would check its subtypes. Each operator would keep its existing 
implementation-specific type restrictions.
   
   Nereids already exposes the operands at each call site.
   
   - Use `Sort#getOrderKeys()` for `LogicalSort` and `TopN`, and 
`Aggregate#getGroupByExpressions()` for ordinary grouping and grouping sets. 
`Repeat` already implements `Aggregate` and flattens its grouping sets. 
`ProjectWithDistinctToAggregate` also puts the projected columns of `SELECT 
DISTINCT` on this path.
   - For ordering inside an expression, override 
`OrderExpression#checkInputDataTypesInternal()` and check its child. 
`Expression#checkInputDataTypes()` already visits it for both window and 
aggregate ordering. Window partition keys can use the grouping check.
   - For explicit aggregate `DISTINCT`, use 
`AggregateFunction#getDistinctArguments()` to identify the operands. Keep 
`Count#checkLegalityAfterRewrite()` in place so the existing bitmap and HLL 
rewrites still run first. For set operations, check the output columns when 
rows must be matched or deduplicated. `UNION ALL` only concatenates rows.



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