fix bug when load data into table partitioned by columns containing auto-inc value

This commit is contained in:
wjhh2008
2023-04-03 14:14:31 +00:00
committed by ob-robot
parent 5d8cb11b64
commit 0765e69043
2 changed files with 15 additions and 2 deletions

View File

@ -1446,9 +1446,13 @@ int ObAutoincrementService::calc_prev_value(const uint64_t max_value,
int ret = OB_SUCCESS;
if (max_value <= offset) {
prev_value = max_value;
} else {
if (0 == increment) {
ret = OB_ERR_UNEXPECTED;
} else {
prev_value = ((max_value - offset) / increment) * increment + offset;
}
}
LOG_INFO("out of range for column. calc prev value",
K(prev_value), K(max_value), K(offset), K(increment));
return ret;

View File

@ -1063,7 +1063,8 @@ int ObLoadDataSPImpl::exec_shuffle(int64_t task_id, ObShuffleTaskHandle *handle)
} else if (OB_FAIL(handle->generator.gen_insert_values(insert_values, str_buf))) {
LOG_WARN("fail to generate insert values", K(ret));
} else if (nullptr == handle->calc_tablet_id_expr) {
tablet_id = handle->datafrag_mgr.get_tablet_ids().at(0);
int64_t idx = task_id % handle->datafrag_mgr.get_tablet_ids().count();
tablet_id = handle->datafrag_mgr.get_tablet_ids().at(idx);
} else {
for (int i = 0; i < handle->parser.get_fields_per_line().count(); ++i) {
ObCSVGeneralParser::FieldValue &str_v = handle->parser.get_fields_per_line().at(i);
@ -2568,6 +2569,14 @@ int ObLoadDataSPImpl::ToolBox::build_calc_partid_expr(ObExecContext &ctx,
}
}
if (OB_SUCC(ret)) {
bool part_key_has_autoinc = false;
OZ (insert_stmt->part_key_has_auto_inc(part_key_has_autoinc));
if (part_key_has_autoinc) {
calc_tablet_id_expr = NULL;
}
}
LOG_DEBUG("LOAD DATA check insert info",
K(column_convert_exprs), K(column_exprs), KPC(calc_partid_expr),