@@ -452,15 +452,15 @@ void PhysicalImport::CSVRowHandler(void *context) {
452
452
UniquePtr<BlockEntry> block_entry = std::move (parser_context->block_entry_ );
453
453
454
454
// if column count is larger than columns defined from schema, extra columns are abandoned
455
- if (column_count != table_entry->ColumnCount ()) {
456
- UniquePtr<String> err_msg = MakeUnique<String>(
457
- fmt::format (" CSV file row count isn't match with table schema, row id: {}, column_count = {}, table_entry->ColumnCount = {}." ,
458
- parser_context->row_count_ ,
459
- column_count,
460
- table_entry->ColumnCount ()));
461
- LOG_ERROR (*err_msg);
462
- RecoverableError (Status::ColumnCountMismatch (*err_msg));
463
- }
455
+ // if (column_count != table_entry->ColumnCount()) {
456
+ // UniquePtr<String> err_msg = MakeUnique<String>(
457
+ // fmt::format("CSV file row count isn't match with table schema, row id: {}, column_count = {}, table_entry->ColumnCount = {}.",
458
+ // parser_context->row_count_,
459
+ // column_count,
460
+ // table_entry->ColumnCount()));
461
+ // LOG_ERROR(*err_msg);
462
+ // RecoverableError(Status::ColumnCountMismatch(*err_msg));
463
+ // }
464
464
465
465
// append data to segment entry
466
466
for (SizeT column_idx = 0 ; column_idx < column_count; ++column_idx) {
@@ -480,6 +480,16 @@ void PhysicalImport::CSVRowHandler(void *context) {
480
480
}
481
481
}
482
482
}
483
+ for (SizeT column_idx = column_count; column_idx < table_entry->ColumnCount (); ++column_idx) {
484
+ auto column_def = table_entry->GetColumnDefByID (column_idx);
485
+ auto &column_vector = parser_context->column_vectors_ [column_idx];
486
+ if (column_def->has_default_value ()) {
487
+ auto const_expr = dynamic_cast <ConstantExpr *>(column_def->default_expr_ .get ());
488
+ column_vector.AppendByConstantExpr (const_expr);
489
+ } else {
490
+ RecoverableError (Status::ImportFileFormatError (fmt::format (" Column {} is empty." , column_def->name_ )));
491
+ }
492
+ }
483
493
block_entry->IncreaseRowCount (1 );
484
494
++parser_context->row_count_ ;
485
495
0 commit comments