[fix](statstics) Incorrectly using the number of buckets to determine whether the table is partitioned (#13218)

This commit is contained in:
Kikyou1997
2022-10-10 17:22:24 +08:00
committed by GitHub
parent 54e6f12110
commit f007e0aed0
2 changed files with 6 additions and 3 deletions

View File

@ -20,6 +20,7 @@ package org.apache.doris.analysis;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.PartitionType;
import org.apache.doris.catalog.Table;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.ErrorCode;
@ -148,7 +149,7 @@ public class AlterColumnStatsStmt extends DdlStmt {
}
if (optPartitionNames != null) {
if (!olapTable.isPartitioned()) {
if (olapTable.getPartitionInfo().getType().equals(PartitionType.UNPARTITIONED)) {
throw new AnalysisException("Not a partitioned table: " + olapTable.getName());
}
@ -162,7 +163,7 @@ public class AlterColumnStatsStmt extends DdlStmt {
}
partitionNames.addAll(optPartitionNames.getPartitionNames());
} else {
if (olapTable.isPartitioned()) {
if (!olapTable.getPartitionInfo().getType().equals(PartitionType.UNPARTITIONED)) {
throw new AnalysisException("For partitioned tables, partitions should be specified");
}
}

View File

@ -26,6 +26,7 @@ import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.PartitionType;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
@ -91,7 +92,8 @@ public class StatisticsManager {
List<String> partitionNames = stmt.getPartitionNames();
Map<StatsType, String> statsTypeToValue = stmt.getStatsTypeToValue();
if ((partitionNames.isEmpty()) && table.isPartitioned()) {
if ((partitionNames.isEmpty()) && table instanceof OlapTable
&& !((OlapTable) table).getPartitionInfo().getType().equals(PartitionType.UNPARTITIONED)) {
throw new AnalysisException("Partitioned table must specify partition name.");
}