diff --git a/src/sql/das/ob_das_scan_op.cpp b/src/sql/das/ob_das_scan_op.cpp index 1d7ba10e6b..b65b182383 100644 --- a/src/sql/das/ob_das_scan_op.cpp +++ b/src/sql/das/ob_das_scan_op.cpp @@ -313,6 +313,7 @@ int ObDASScanOp::init_scan_param() } } scan_param_.external_file_format_.csv_format_.file_column_nums_ = static_cast(max_idx); + scan_param_.external_file_format_.csv_format_.ignore_extra_fields_ = true; } } LOG_DEBUG("init scan param", K(ret), K(scan_param_)); diff --git a/src/sql/engine/cmd/ob_load_data_parser.h b/src/sql/engine/cmd/ob_load_data_parser.h index fd43ec831a..14870e89db 100644 --- a/src/sql/engine/cmd/ob_load_data_parser.h +++ b/src/sql/engine/cmd/ob_load_data_parser.h @@ -40,6 +40,7 @@ struct ObCSVGeneralFormat { cs_type_(common::CHARSET_INVALID), skip_header_lines_(0), skip_blank_lines_(false), + ignore_extra_fields_(false), trim_space_(false), null_if_(), empty_field_as_null_(false), @@ -65,6 +66,7 @@ struct ObCSVGeneralFormat { common::ObCharsetType cs_type_; // charset type of format strings int64_t skip_header_lines_; bool skip_blank_lines_; + bool ignore_extra_fields_; bool trim_space_; common::ObArrayWrap null_if_; bool empty_field_as_null_; @@ -442,7 +444,8 @@ int ObCSVGeneralParser::scan_proto(const char *&str, } if (OB_LIKELY(find_new_line) || is_end_file) { if (!format_.skip_blank_lines_ || field_idx > 0) { - if (field_idx != format_.file_column_nums_) { + if (field_idx < format_.file_column_nums_ + || (field_idx > format_.file_column_nums_ && !format_.ignore_extra_fields_)) { ret = handle_irregular_line(field_idx, line_no, errors); } if (OB_SUCC(ret)) {