Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

package org.apache.doris.analysis;

import org.apache.doris.catalog.AggregateType;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.DistributionInfo;
import org.apache.doris.catalog.DistributionInfo.DistributionInfoType;
import org.apache.doris.catalog.HashDistributionInfo;
import org.apache.doris.catalog.DistributionInfo;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.io.Text;
Expand Down Expand Up @@ -102,10 +103,14 @@ public DistributionInfo toDistributionInfo(List<Column> columns) throws DdlExcep
boolean find = false;
for (Column column : columns) {
if (column.getName().equalsIgnoreCase(colName)) {
if (!column.isKey()) {
if (!column.isKey() && column.getAggregationType() != AggregateType.NONE) {
throw new DdlException("Distribution column[" + colName + "] is not key column");
}

if (column.getType().isFloatingPointType()) {
throw new DdlException("Floating point type column can not be distribution column");
}

distributionColumns.add(column);
find = true;
break;
Expand Down
17 changes: 13 additions & 4 deletions fe/src/main/java/org/apache/doris/analysis/RangePartitionDesc.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.analysis;

import org.apache.doris.analysis.PartitionKeyDesc.PartitionRangeType;
import org.apache.doris.catalog.AggregateType;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.PartitionInfo;
import org.apache.doris.catalog.PartitionType;
Expand Down Expand Up @@ -71,8 +72,11 @@ public void analyze(List<ColumnDef> columnDefs, Map<String, String> otherPropert
boolean found = false;
for (ColumnDef columnDef : columnDefs) {
if (columnDef.getName().equals(partitionCol)) {
if (!columnDef.isKey()) {
throw new AnalysisException("Only key column can be partition column");
if (!columnDef.isKey() && columnDef.getAggregateType() != AggregateType.NONE) {
throw new AnalysisException("The partition column could not be aggregated column");
}
if (columnDef.getType().isFloatingPointType()) {
throw new AnalysisException("Floating point type column can not be partition column");
}
found = true;
break;
Expand Down Expand Up @@ -145,9 +149,14 @@ public PartitionInfo toPartitionInfo(List<Column> schema, Map<String, Long> part
boolean find = false;
for (Column column : schema) {
if (column.getName().equalsIgnoreCase(colName)) {
if (!column.isKey()) {
throw new DdlException("Partition column[" + colName + "] is not key column");
if (!column.isKey() && column.getAggregationType() != AggregateType.NONE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need a second check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical issues...
It is OK, may be removed in future.

throw new DdlException("The partition column could not be aggregated column");
}

if (column.getType().isFloatingPointType()) {
throw new DdlException("Floating point type column can not be partition column");
}

try {
RangePartitionInfo.checkRangeColumnType(column);
} catch (AnalysisException e) {
Expand Down
Loading