You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:51:20 UTC
[GitHub] [incubator-doris] ucasFL opened a new pull request #6023: Support alter default bucket_num of table
ucasFL opened a new pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023
## Proposed changes
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
## Types of changes
What types of changes does your code introduce to Doris?
_Put an `x` in the boxes that apply_
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation Update (if none of the other choices apply)
- [ ] Code refactor (Modify the code structure, format the code, etc...)
## Checklist
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
- [ ] I have created an issue on (Fix #ISSUE) and described the bug/feature there in detail
- [ ] Compiling and unit tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] If these changes need document changes, I have updated the document
- [ ] Any dependent changes have been merged
## Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-867440560
Updated. @liutang123
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r663602453
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyDistributionClause.java
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.alter.AlterOpType;
+import org.apache.doris.common.AnalysisException;
+
+// clause which is used to modify the default bucket number of hash distribution
+// MODIFY DISTRIBUTION DISTRIBUTED BY HASH('key') BUCKETS number;
+public class ModifyDistributionClause extends AlterTableClause {
+
+ private DistributionDesc distributionDesc;
+
+ public DistributionDesc getDistributionDesc() {
+ return distributionDesc;
+ }
+
+ public ModifyDistributionClause(DistributionDesc distributionDesc) {
+ super(AlterOpType.MODIFY_DISTRIBUTION);
+ this.distributionDesc = distributionDesc;
+ this.needTableStable = false;
+ }
+
+ @Override
+ public void analyze(Analyzer analyzer) throws AnalysisException {
Review comment:
PrivPredicate.ALTER
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
morningman commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-877580284
> Can this PR be merged? @EmmyMiao87 @morningman
Sure, it will be merged tomorrow if there is no other comments.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659925578
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,74 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
Review comment:
Updated!
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r661113651
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyDistributionClause.java
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.alter.AlterOpType;
+import org.apache.doris.common.AnalysisException;
+
+// clause which is used to modify the default bucket number of hash distribution
+// MODIFY DISTRIBUTION DISTRIBUTED BY HASH('key') BUCKETS number;
+public class ModifyDistributionClause extends AlterTableClause {
+
+ private DistributionDesc distributionDesc;
+
+ public DistributionDesc getDistributionDesc() {
+ return distributionDesc;
+ }
+
+ public ModifyDistributionClause(DistributionDesc distributionDesc) {
+ super(AlterOpType.MODIFY_DISTRIBUTION);
+ this.distributionDesc = distributionDesc;
+ this.needTableStable = false;
+ }
+
+ @Override
+ public void analyze(Analyzer analyzer) throws AnalysisException {
Review comment:
which permissions should be checked in here?
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r651746299
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5496,6 +5496,24 @@ public void modifyTableDefaultReplicationNum(Database db, OlapTable table, Map<S
properties.get(PropertyAnalyzer.PROPERTIES_REPLICATION_NUM));
}
+ // The caller need to hold the db write lock
Review comment:
Updated.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659926576
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5550,53 +5550,55 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
olapTable.writeLock();
- if (olapTable.isColocateTable()) {
- throw new DdlException("Cannot change default bucket number of colocate table.");
- }
-
- if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
- throw new DdlException("Only support change partitioned table's distribution.");
- }
-
- 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());
+ try {
Review comment:
Use 4 spaces instead of tab
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5550,53 +5550,55 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
olapTable.writeLock();
- if (olapTable.isColocateTable()) {
- throw new DdlException("Cannot change default bucket number of colocate table.");
- }
-
- if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
- throw new DdlException("Only support change partitioned table's distribution.");
- }
-
- 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());
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
}
-
- 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 (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
}
-
- int bucketNum = hashDistributionInfo.getBucketNum();
- if (bucketNum <= 0) {
- throw new DdlException("Cannot assign hash distribution buckets less than 1");
+
+ DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
+ if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
+ throw new DdlException("Cannot change default bucket number of distribution type " + defaultDistributionInfo.getType());
}
-
- defaultDistributionInfo.setBucketNum(bucketNum);
-
- ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
- editLog.logModifyDefaultDistributionBucketNum(info);
- LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
- }
- olapTable.writeUnlock();
-
+
+ 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);
+ }
+
+ int bucketNum = hashDistributionInfo.getBucketNum();
+ if (bucketNum <= 0) {
+ throw new DdlException("Cannot assign hash distribution buckets less than 1");
+ }
+
+ defaultDistributionInfo.setBucketNum(bucketNum);
+
+ ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
+ editLog.logModifyDefaultDistributionBucketNum(info);
+ LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
+ }
+ } finally {
+ olapTable.writeUnlock();
+ }
Review comment:
tab to space.
You can modify your IDEA settings to do this automatically
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r665807625
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5577,6 +5579,76 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
+
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
+ }
+
+ if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
+ }
+
+ 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);
+ }
+
+ int bucketNum = hashDistributionInfo.getBucketNum();
+ if (bucketNum <= 0) {
+ throw new DdlException("Cannot assign hash distribution buckets less than 1");
+ }
+
+ defaultDistributionInfo.setBucketNum(bucketNum);
+
+ ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
+ editLog.logModifyDefaultDistributionBucketNum(info);
+ LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
+ }
+ } finally {
+ olapTable.writeUnlock();
+ }
+ }
+
+ public void replayModifyTableDefaultDistributionBucketNum(short opCode, ModifyTableDefaultDistributionBucketNumOperationLog info) {
+ long dbId = info.getDbId();
+ long tableId = info.getTableId();
+ int bucketNum = info.getBucketNum();
+
+ Database db = getDb(dbId);
+ OlapTable olapTable = (OlapTable) db.getTable(tableId);
Review comment:
Need to check `if (olapTable == null)`.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] liutang123 commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
liutang123 commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-867396950
Add an UT.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659452088
##########
File path: fe/fe-core/src/main/cup/sql_parser.cup
##########
@@ -1010,6 +1010,10 @@ alter_table_clause ::=
{:
RESULT = new EnableFeatureClause(featureName, properties);
:}
+ | KW_MODIFY KW_DISTRIBUTION opt_distribution:distribution
Review comment:
Please modify the document of Alter stmt in English and Chinese.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] EmmyMiao87 commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-875224122
The NewDorisTest(p0) didn't passed. Maybe you should rebase master.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] liutang123 merged pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
liutang123 merged pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659925578
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,74 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
Review comment:
Updated!
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5550,53 +5550,55 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
olapTable.writeLock();
- if (olapTable.isColocateTable()) {
- throw new DdlException("Cannot change default bucket number of colocate table.");
- }
-
- if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
- throw new DdlException("Only support change partitioned table's distribution.");
- }
-
- 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());
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
}
-
- 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 (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
}
-
- int bucketNum = hashDistributionInfo.getBucketNum();
- if (bucketNum <= 0) {
- throw new DdlException("Cannot assign hash distribution buckets less than 1");
+
+ DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
+ if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
+ throw new DdlException("Cannot change default bucket number of distribution type " + defaultDistributionInfo.getType());
}
-
- defaultDistributionInfo.setBucketNum(bucketNum);
-
- ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
- editLog.logModifyDefaultDistributionBucketNum(info);
- LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
- }
- olapTable.writeUnlock();
-
+
+ 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);
+ }
+
+ int bucketNum = hashDistributionInfo.getBucketNum();
+ if (bucketNum <= 0) {
+ throw new DdlException("Cannot assign hash distribution buckets less than 1");
+ }
+
+ defaultDistributionInfo.setBucketNum(bucketNum);
+
+ ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
+ editLog.logModifyDefaultDistributionBucketNum(info);
+ LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
+ }
+ } finally {
+ olapTable.writeUnlock();
+ }
Review comment:
OK.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] liutang123 commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r663838345
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyDistributionClause.java
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.alter.AlterOpType;
+import org.apache.doris.common.AnalysisException;
+
+// clause which is used to modify the default bucket number of hash distribution
+// MODIFY DISTRIBUTION DISTRIBUTED BY HASH('key') BUCKETS number;
+public class ModifyDistributionClause extends AlterTableClause {
+
+ private DistributionDesc distributionDesc;
+
+ public DistributionDesc getDistributionDesc() {
+ return distributionDesc;
+ }
+
+ public ModifyDistributionClause(DistributionDesc distributionDesc) {
+ super(AlterOpType.MODIFY_DISTRIBUTION);
+ this.distributionDesc = distributionDesc;
+ this.needTableStable = false;
+ }
+
+ @Override
+ public void analyze(Analyzer analyzer) throws AnalysisException {
Review comment:
It seems that it has been checked in `AlterTableStmt.analyze()`.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r665850451
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5577,6 +5579,76 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
+
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
+ }
+
+ if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
+ }
+
+ 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);
+ }
+
+ int bucketNum = hashDistributionInfo.getBucketNum();
+ if (bucketNum <= 0) {
+ throw new DdlException("Cannot assign hash distribution buckets less than 1");
+ }
+
+ defaultDistributionInfo.setBucketNum(bucketNum);
+
+ ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
+ editLog.logModifyDefaultDistributionBucketNum(info);
+ LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
+ }
+ } finally {
+ olapTable.writeUnlock();
+ }
+ }
+
+ public void replayModifyTableDefaultDistributionBucketNum(short opCode, ModifyTableDefaultDistributionBucketNumOperationLog info) {
+ long dbId = info.getDbId();
+ long tableId = info.getTableId();
+ int bucketNum = info.getBucketNum();
+
+ Database db = getDb(dbId);
+ OlapTable olapTable = (OlapTable) db.getTable(tableId);
Review comment:
Updated!
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-875293746
> The NewDorisTest(p0) didn't passed. Maybe you should rebase master.
Thanks, all tests passed now.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r663838345
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyDistributionClause.java
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.alter.AlterOpType;
+import org.apache.doris.common.AnalysisException;
+
+// clause which is used to modify the default bucket number of hash distribution
+// MODIFY DISTRIBUTION DISTRIBUTED BY HASH('key') BUCKETS number;
+public class ModifyDistributionClause extends AlterTableClause {
+
+ private DistributionDesc distributionDesc;
+
+ public DistributionDesc getDistributionDesc() {
+ return distributionDesc;
+ }
+
+ public ModifyDistributionClause(DistributionDesc distributionDesc) {
+ super(AlterOpType.MODIFY_DISTRIBUTION);
+ this.distributionDesc = distributionDesc;
+ this.needTableStable = false;
+ }
+
+ @Override
+ public void analyze(Analyzer analyzer) throws AnalysisException {
Review comment:
It seems that it has been checked in `AlterTableStmt.analyze()`.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl edited a comment on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl edited a comment on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-878220226
> > Can this PR be merged? @EmmyMiao87 @morningman
>
> Sure, it will be merged tomorrow if there is no other comments.
Looks like tomorrow has passed :)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-878220226
> > Can this PR be merged? @EmmyMiao87 @morningman
>
> Sure, it will be merged tomorrow if there is no other comments.
> > Can this PR be merged? @EmmyMiao87 @morningman
>
> Sure, it will be merged tomorrow if there is no other comments.
Looks like tomorrow has passed :)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r661098615
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,76 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
+
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
+ }
+
+ if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
+ }
+
+ DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
+ if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
Review comment:
You should use your code format of IDE
##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/ModifyDistributionClause.java
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.alter.AlterOpType;
+import org.apache.doris.common.AnalysisException;
+
+// clause which is used to modify the default bucket number of hash distribution
+// MODIFY DISTRIBUTION DISTRIBUTED BY HASH('key') BUCKETS number;
+public class ModifyDistributionClause extends AlterTableClause {
+
+ private DistributionDesc distributionDesc;
+
+ public DistributionDesc getDistributionDesc() {
+ return distributionDesc;
+ }
+
+ public ModifyDistributionClause(DistributionDesc distributionDesc) {
+ super(AlterOpType.MODIFY_DISTRIBUTION);
+ this.distributionDesc = distributionDesc;
+ this.needTableStable = false;
+ }
+
+ @Override
+ public void analyze(Analyzer analyzer) throws AnalysisException {
Review comment:
Have you checked the permissions for this operation?
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,76 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
+
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
+ }
+
+ if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
+ }
+
+ DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
+ if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
Review comment:
```suggestion
if (defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
```
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659902634
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,74 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
Review comment:
The pattern of lock should be:
```
olapTable.writeLock();
try {
......
} finally {
olapTable.writeUnlock();
}
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5550,53 +5550,55 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
olapTable.writeLock();
- if (olapTable.isColocateTable()) {
- throw new DdlException("Cannot change default bucket number of colocate table.");
- }
-
- if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
- throw new DdlException("Only support change partitioned table's distribution.");
- }
-
- 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());
+ try {
Review comment:
Use 4 spaces instead of tab
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5550,53 +5550,55 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
olapTable.writeLock();
- if (olapTable.isColocateTable()) {
- throw new DdlException("Cannot change default bucket number of colocate table.");
- }
-
- if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
- throw new DdlException("Only support change partitioned table's distribution.");
- }
-
- 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());
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
}
-
- 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 (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
}
-
- int bucketNum = hashDistributionInfo.getBucketNum();
- if (bucketNum <= 0) {
- throw new DdlException("Cannot assign hash distribution buckets less than 1");
+
+ DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
+ if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
+ throw new DdlException("Cannot change default bucket number of distribution type " + defaultDistributionInfo.getType());
}
-
- defaultDistributionInfo.setBucketNum(bucketNum);
-
- ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
- editLog.logModifyDefaultDistributionBucketNum(info);
- LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
- }
- olapTable.writeUnlock();
-
+
+ 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);
+ }
+
+ int bucketNum = hashDistributionInfo.getBucketNum();
+ if (bucketNum <= 0) {
+ throw new DdlException("Cannot assign hash distribution buckets less than 1");
+ }
+
+ defaultDistributionInfo.setBucketNum(bucketNum);
+
+ ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
+ editLog.logModifyDefaultDistributionBucketNum(info);
+ LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
+ }
+ } finally {
+ olapTable.writeUnlock();
+ }
Review comment:
tab to space.
You can modify your IDEA settings to do this automatically
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659902634
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5545,6 +5547,74 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
}
}
+ public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
+ olapTable.writeLock();
Review comment:
The pattern of lock should be:
```
olapTable.writeLock();
try {
......
} finally {
olapTable.writeUnlock();
}
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659677994
##########
File path: fe/fe-core/src/main/cup/sql_parser.cup
##########
@@ -1010,6 +1010,10 @@ alter_table_clause ::=
{:
RESULT = new EnableFeatureClause(featureName, properties);
:}
+ | KW_MODIFY KW_DISTRIBUTION opt_distribution:distribution
Review comment:
DONE!
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasfl commented on pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasfl commented on pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#issuecomment-877578000
Can this PR be merged? @EmmyMiao87 @morningman
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] ucasFL commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
ucasFL commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r659931160
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5550,53 +5550,55 @@ public void replayModifyTableProperty(short opCode, ModifyTablePropertyOperation
public void modifyDefaultDistributionBucketNum(Database db, OlapTable olapTable, ModifyDistributionClause modifyDistributionClause) throws DdlException {
olapTable.writeLock();
- if (olapTable.isColocateTable()) {
- throw new DdlException("Cannot change default bucket number of colocate table.");
- }
-
- if (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
- throw new DdlException("Only support change partitioned table's distribution.");
- }
-
- 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());
+ try {
+ if (olapTable.isColocateTable()) {
+ throw new DdlException("Cannot change default bucket number of colocate table.");
}
-
- 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 (olapTable.getPartitionInfo().getType() != PartitionType.RANGE) {
+ throw new DdlException("Only support change partitioned table's distribution.");
}
-
- int bucketNum = hashDistributionInfo.getBucketNum();
- if (bucketNum <= 0) {
- throw new DdlException("Cannot assign hash distribution buckets less than 1");
+
+ DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
+ if(defaultDistributionInfo.getType() != DistributionInfoType.HASH) {
+ throw new DdlException("Cannot change default bucket number of distribution type " + defaultDistributionInfo.getType());
}
-
- defaultDistributionInfo.setBucketNum(bucketNum);
-
- ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
- editLog.logModifyDefaultDistributionBucketNum(info);
- LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
- }
- olapTable.writeUnlock();
-
+
+ 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);
+ }
+
+ int bucketNum = hashDistributionInfo.getBucketNum();
+ if (bucketNum <= 0) {
+ throw new DdlException("Cannot assign hash distribution buckets less than 1");
+ }
+
+ defaultDistributionInfo.setBucketNum(bucketNum);
+
+ ModifyTableDefaultDistributionBucketNumOperationLog info = new ModifyTableDefaultDistributionBucketNumOperationLog(db.getId(), olapTable.getId(), bucketNum);
+ editLog.logModifyDefaultDistributionBucketNum(info);
+ LOG.info("modify table[{}] default bucket num to {}", olapTable.getName(), bucketNum);
+ }
+ } finally {
+ olapTable.writeUnlock();
+ }
Review comment:
OK.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] caiconghui commented on a change in pull request #6023: Support alter default bucket_num of table
Posted by GitBox <gi...@apache.org>.
caiconghui commented on a change in pull request #6023:
URL: https://github.com/apache/incubator-doris/pull/6023#discussion_r651631647
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5496,6 +5496,24 @@ public void modifyTableDefaultReplicationNum(Database db, OlapTable table, Map<S
properties.get(PropertyAnalyzer.PROPERTIES_REPLICATION_NUM));
}
+ // The caller need to hold the db write lock
Review comment:
```suggestion
// The caller need to hold the table write lock
```
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org