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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MapAggregateFunction.java:
##########
@@ -56,8 +56,20 @@ public FunctionSignature customSignature() {
                 .args(MapType.of(keyType, argumentValueType));
     }
 
+    @Override
+    public void checkLegalityBeforeTypeCoercion() {
+        if (getMapType().getKeyType().isSpatialType()) {

Review Comment:
   [P2] Reject spatial MAP values for DISTINCT aggregates
   
   The new guard checks only MAP keys, so `COUNT_MAP(DISTINCT map(1, geom))` 
passes with imported GEOMETRY or GEOGRAPHY values. A reduced input plan 
inferred from the rules is:
   
   ```text
   Aggregate[count_map(DISTINCT m)]
     Project[map(1, geom) AS m]
       IcebergScan[geom]
   ```
   
   `SplitAggMultiPhaseWithoutGbyKey` takes the three/four-phase path for 
CountMap; `AggregateUtils.getAllKeySet` includes `m`, and 
`SplitAggBaseRule.splitDeduplicateOnePhase` creates a physical `GROUP BY m` 
after `CheckAnalysis`. The consuming count_map then has DISTINCT cleared. Thus 
the new spatial grouping rejection never sees this generated key.
   
   For two non-NULL rows containing the same POINT(1 2), once in little-endian 
WKB and once in big-endian WKB, ColumnMap/ColumnSpatial serialize different raw 
keys. Consequently `SELECT element_at(count_map(DISTINCT map(1, geom)), 1) FROM 
t` counts 2, versus 1 with identical encodings, instead of rejecting 
unsupported spatial DISTINCT. This is a separate aggregate family/admission 
site from the repaired ARRAY_AGG/COLLECT_LIST DISTINCT paths. Reject 
recursively spatial DISTINCT arguments here or centrally before lowering, 
retaining nondistinct ordinary-key COUNT_MAP.



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