Deny specify partition for unpartitioned table (#1319)

This commit is contained in:
ZHAO Chun
2019-06-15 18:19:56 +08:00
committed by Mingyu Chen
parent 9d03ba236b
commit 30028bc35b
2 changed files with 12 additions and 1 deletions

View File

@ -320,7 +320,11 @@ Status BrokerScanNode::scanner_scan(
continue;
}
if (scan_range.params.__isset.partition_ids) {
// The reason we check if partition_expr_ctxs is empty is when loading data to
// a unpartitioned table who has no partition_expr_ctxs, user can specify
// a partition name. And we check here to aovid this check and make our
// process run as normal
if (scan_range.params.__isset.partition_ids && !partition_expr_ctxs.empty()) {
int64_t partition_id = get_partition_id(partition_expr_ctxs, row);
if (partition_id == -1 ||
!std::binary_search(scan_range.params.partition_ids.begin(),

View File

@ -667,6 +667,13 @@ public class Load {
throw new DdlException("Table [" + tableName + "] is not olap table");
}
// check partition
if (dataDescription.getPartitionNames() != null &&
!dataDescription.getPartitionNames().isEmpty() &&
((OlapTable) table).getPartitionInfo().getType() == PartitionType.UNPARTITIONED) {
ErrorReport.reportDdlException(ErrorCode.ERR_PARTITION_CLAUSE_NO_ALLOWED);
}
if (((OlapTable) table).getState() == OlapTableState.RESTORE) {
throw new DdlException("Table [" + tableName + "] is under restore");
}