nooneuse commented on code in PR #66307:
URL: https://github.com/apache/doris/pull/66307#discussion_r3888180882


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java:
##########
@@ -204,12 +251,46 @@ public PhysicalProperties visitPhysicalHashAggregate(
                         && 
isShuffleCompatible(childOutputProperty.getDistributionSpec())) {
                     return PhysicalProperties.ANY;
                 }
+                if 
(childOutputProperty.getNaturalDistributionMappingSpec().isPresent()) {
+                    return computeAggregateOutputProperties(agg, 
childOutputProperty)

Review Comment:
   okay



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/constraint/ConstraintManager.java:
##########
@@ -945,6 +1204,78 @@ private void validateColumnsExist(TableIf table,
         }
     }
 
+    private void validateDistributionMappingConstraint(TableNameInfo 
tableNameInfo,
+            OlapTable table, DistributionMappingConstraint constraint) {
+        if (table.getCatalogId() != InternalCatalog.INTERNAL_CATALOG_ID) {
+            throw new AnalysisException("Distribution mapping constraint only 
supports internal OLAP tables");
+        }
+        if (table.isTemporary()) {
+            throw new AnalysisException("Distribution mapping constraint does 
not support temporary tables");
+        }
+        validateColumnsExist(table, constraint.getDeterminantColumnNames(), 
toKey(tableNameInfo));
+        validateColumnsExist(table, constraint.getDistributionColumnNames(), 
toKey(tableNameInfo));
+
+        TreeSet<String> determinantColumns = new 
TreeSet<>(String.CASE_INSENSITIVE_ORDER);
+        determinantColumns.addAll(constraint.getDeterminantColumnNames());
+        if (determinantColumns.size() != 
constraint.getDeterminantColumnNames().size()) {
+            throw new AnalysisException("Determinant columns in distribution 
mapping constraint must be unique");
+        }
+        TreeSet<String> distributionColumns = new 
TreeSet<>(String.CASE_INSENSITIVE_ORDER);
+        distributionColumns.addAll(constraint.getDistributionColumnNames());
+        if (distributionColumns.size() != 
constraint.getDistributionColumnNames().size()) {
+            throw new AnalysisException("Distribution columns in distribution 
mapping constraint must be unique");
+        }
+
+        if (!(table.getDefaultDistributionInfo() instanceof 
HashDistributionInfo)) {
+            throw new AnalysisException("Distribution mapping constraint 
requires hash distribution");
+        }
+        if (!constraint.hasCompatibleDistributionColumns(table)) {
+            throw new AnalysisException("Distribution columns in distribution 
mapping constraint"
+                    + " must be an ordered subset of table distribution 
columns");
+        }
+    }
+
+    /** Reject ADD and restore until every registered FE reports this exact 
build. */
+    public void validateDistributionMappingFeatureCompatibility() {
+        String currentVersion = getCurrentFrontendVersion();

Review Comment:
   right



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