Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix_ckp_ts
Browse files Browse the repository at this point in the history
  • Loading branch information
small-turtle-1 committed Jan 7, 2025
2 parents d3d2582 + 8dd53dd commit 0e46a68
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/executor/operator/physical_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,9 @@ void PhysicalImport::CSVRowHandler(void *context) {
RecoverableError(status);
}

Vector<String> parsed_cell;
parsed_cell.reserve(column_count);

// append data to segment entry
for (SizeT column_idx = 0; column_idx < column_count; ++column_idx) {
ZsvCell cell = parser_context->parser_.GetCell(column_idx);
Expand All @@ -802,11 +805,13 @@ void PhysicalImport::CSVRowHandler(void *context) {
str_view = std::string_view((char *)cell.str, cell.len);
auto &column_vector = parser_context->column_vectors_[column_idx];
column_vector.AppendByStringView(str_view);
parsed_cell.emplace_back(str_view);
} else {
if (column_def->has_default_value()) {
auto const_expr = dynamic_cast<ConstantExpr *>(column_def->default_expr_.get());
auto &column_vector = parser_context->column_vectors_[column_idx];
column_vector.AppendByConstantExpr(const_expr);
parsed_cell.emplace_back(const_expr->ToString());
} else {
Status status = Status::ImportFileFormatError(
fmt::format("No value in column {} in CSV of row number: {}", column_def->name_, parser_context->row_count_));
Expand All @@ -821,12 +826,20 @@ void PhysicalImport::CSVRowHandler(void *context) {
auto const_expr = dynamic_cast<ConstantExpr *>(column_def->default_expr_.get());
column_vector.AppendByConstantExpr(const_expr);
} else {
Status status =
Status::ImportFileFormatError(fmt::format("No value in column {} index {} in CSV of row number: {}, current row has column count: {}",
column_def->name_,
column_idx,
parser_context->row_count_,
column_count));
String parsed_row;
for (auto &cell : parsed_cell) {
parsed_row += cell;
parsed_row += " ";
}

Status status = Status::ImportFileFormatError(fmt::format("No value in column {} index {} in CSV of row number: {}, table has column "
"count: {}, current row has column count: {}, parsed row: {}",
column_def->name_,
column_idx,
parser_context->row_count_,
table_entry->ColumnCount(),
column_count,
parsed_row));
RecoverableError(status);
}
}
Expand Down

0 comments on commit 0e46a68

Please sign in to comment.