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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MinBy.java:
##########
@@ -66,6 +66,11 @@ private MinBy(NullableAggregateFunctionParams 
functionParams) {
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
+        for (Expression argument : getArguments()) {
+            if (argument.getDataType().isSpatialType()) {

Review Comment:
   [P2] Reject nested spatial ordering keys in MIN_BY/MAX_BY
   
   The scalar-only check admits `min_by(id, array(geom))` (and imported 
`ARRAY<GEOMETRY/GEOGRAPHY>` keys). A reduced plan is:
   
   ```text
   Aggregate[min_by(id, key)]
     Project[id, array(geom) AS key]
       IcebergScan[id, geom]
   ```
   
   The adjacent ARRAY exception and ANY signatures preserve this key; no GROUP 
BY/DISTINCT gate applies. BE selects `SingleValueDataColumn`, whose extrema 
comparison goes through `ColumnArray::compare_at` to raw-WKB 
`ColumnSpatial::compare_at`. For rows `(1, POINT(1 2))` and `(2, POINT(3 4))`, 
both little endian, the minimum selects id 2; encoding only the first point in 
big endian makes it select id 1 without changing either geometry. MAX_BY 
reverses the result. The new legality test positively admits this nested-key 
path.
   
   This is distinct from the repaired scalar missing-factory finding: the ARRAY 
factory executes successfully and reintroduces spatial extrema through its 
ordering key. Reject spatial leaves recursively in argument 1, including 
state/rewrite checks, while retaining nested spatial result values with 
ordinary keys. Cover both spatial kinds and endian variants.



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