liutang123 commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r657676581



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,64 @@ public void replayModifyTableProperty(short opCode, 
ModifyTablePropertyOperation
         }
     }
 
+    public void modifyDefaultDistributionBucketNum(Database db, OlapTable 
olapTable, ModifyDistributionClause modifyDistributionClause) throws 
DdlException {

Review comment:
       Preconditions.checkArgument(olapTable.isWriteLockHeldByCurrentThread());

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,64 @@ public void replayModifyTableProperty(short opCode, 
ModifyTablePropertyOperation
         }
     }
 
+    public void modifyDefaultDistributionBucketNum(Database db, OlapTable 
olapTable, ModifyDistributionClause modifyDistributionClause) throws 
DdlException {
+        if (olapTable.isColocateTable()) {
+            throw new DdlException("Cannot change default bucket number of 
colocate table.");
+        }
+
+        DistributionInfo defaultDistributionInfo = 
olapTable.getDefaultDistributionInfo();
+        if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
+            throw new DdlException("Cannot change default bucket number of 
distribution type " + defaultDistributionInfo.getType());
+        }
+
+        DistributionDesc distributionDesc = 
modifyDistributionClause.getDistributionDesc();
+
+        DistributionInfo distributionInfo = null;
+
+        List<Column> baseSchema = olapTable.getBaseSchema();
+
+        if (distributionDesc != null) {
+            distributionInfo = distributionDesc.toDistributionInfo(baseSchema);
+                // for now. we only support modify distribution's bucket num
+            if (distributionInfo.getType() != DistributionInfoType.HASH) {
+                throw new DdlException("Cannot change distribution type to " + 
distributionInfo.getType());
+            }
+
+            HashDistributionInfo hashDistributionInfo = (HashDistributionInfo) 
distributionInfo;
+            List<Column> newDistriCols = 
hashDistributionInfo.getDistributionColumns();
+            List<Column> defaultDistriCols = ((HashDistributionInfo) 
defaultDistributionInfo).getDistributionColumns();
+            if (!newDistriCols.equals(defaultDistriCols)) {
+                throw new DdlException("Cannot assign hash distribution with 
different distribution cols. "
+                            + "default is: " + defaultDistriCols);
+            }
+            if (hashDistributionInfo.getBucketNum() <= 0) {
+                throw new DdlException("Cannot assign hash distribution 
buckets less than 1");
+            }
+
+            olapTable.setTableDefaultDistributionInfo(distributionInfo);

Review comment:
       Replace this line by `defaultDistributionInfo.setBucketNum(bucketNum);`

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
##########
@@ -184,6 +184,10 @@ public void setTableProperty(TableProperty tableProperty) {
         this.tableProperty = tableProperty;
     }
 
+    public void setTableDefaultDistributionInfo(DistributionInfo 
distributionInfo) {

Review comment:
       Remove this function.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,64 @@ public void replayModifyTableProperty(short opCode, 
ModifyTablePropertyOperation
         }
     }
 
+    public void modifyDefaultDistributionBucketNum(Database db, OlapTable 
olapTable, ModifyDistributionClause modifyDistributionClause) throws 
DdlException {
+        if (olapTable.isColocateTable()) {
+            throw new DdlException("Cannot change default bucket number of 
colocate table.");
+        }
+
+        DistributionInfo defaultDistributionInfo = 
olapTable.getDefaultDistributionInfo();
+        if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
+            throw new DdlException("Cannot change default bucket number of 
distribution type " + defaultDistributionInfo.getType());
+        }
+

Review comment:
       if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
       throw new DdlException("Only support change partitioned table's 
distribution.");
   }




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to