@@ -749,7 +749,7 @@ bool LineError::HandleErrors(StringValueResult &result) {
749749 default :
750750 throw InvalidInputException (" CSV Error not allowed when inserting row" );
751751 }
752- result.error_handler .Error (csv_error);
752+ result.error_handler .Error (csv_error, result. try_row );
753753 }
754754 if (is_error_in_line && scan_id != StringValueScanner::LINE_FINDER_ID) {
755755 if (result.sniffing ) {
@@ -777,7 +777,7 @@ void StringValueResult::NullPaddingQuotedNewlineCheck() const {
777777 // If we have null_padding set, we found a quoted new line, we are scanning the file in parallel; We error.
778778 LinesPerBoundary lines_per_batch (iterator.GetBoundaryIdx (), lines_read);
779779 auto csv_error = CSVError::NullPaddingFail (state_machine.options , lines_per_batch, path);
780- error_handler.Error (csv_error);
780+ error_handler.Error (csv_error, try_row );
781781 }
782782}
783783
@@ -847,13 +847,13 @@ bool StringValueResult::AddRowInternal() {
847847 state_machine.options , cur_col_id - 1 , lines_per_batch, borked_line,
848848 current_line_position.begin .GetGlobalPosition (requested_size, first_nl),
849849 last_position.GetGlobalPosition (requested_size, first_nl), path);
850- error_handler.Error (csv_error);
850+ error_handler.Error (csv_error, try_row );
851851 } else {
852852 auto csv_error = CSVError::IncorrectColumnAmountError (
853853 state_machine.options , cur_col_id - 1 , lines_per_batch, borked_line,
854854 current_line_position.begin .GetGlobalPosition (requested_size, first_nl),
855855 last_position.GetGlobalPosition (requested_size), path);
856- error_handler.Error (csv_error);
856+ error_handler.Error (csv_error, try_row );
857857 }
858858 }
859859 // If we are here we ignore_errors, so we delete this line
@@ -966,6 +966,7 @@ StringValueScanner::StringValueScanner(idx_t scanner_idx_p, const shared_ptr<CSV
966966 lines_read += csv_file_scan->skipped_rows ;
967967 }
968968 iterator.buffer_size = state_machine->options .buffer_size_option .GetValue ();
969+ result.try_row = scanner_idx == LINE_FINDER_ID;
969970}
970971
971972StringValueScanner::StringValueScanner (const shared_ptr<CSVBufferManager> &buffer_manager,
@@ -1710,19 +1711,24 @@ bool StringValueScanner::IsRowValid(CSVIterator ¤t_iterator) const {
17101711 return false ;
17111712 }
17121713 constexpr idx_t result_size = 1 ;
1713- auto scan_finder = make_uniq<StringValueScanner>(StringValueScanner::LINE_FINDER_ID, buffer_manager,
1714- state_machine_strict, make_shared_ptr<CSVErrorHandler>(),
1715- csv_file_scan, false , current_iterator, result_size);
1716- auto &tuples = scan_finder->ParseChunk ();
1717- current_iterator.pos = scan_finder->GetIteratorPosition ();
1718- bool has_error = false ;
1719- if (tuples.current_errors .HasError ()) {
1720- if (tuples.current_errors .Size () != 1 || !tuples.current_errors .HasErrorType (MAXIMUM_LINE_SIZE)) {
1721- // We ignore maximum line size errors
1722- has_error = true ;
1723- }
1724- }
1725- return (tuples.number_of_rows == 1 || tuples.first_line_is_comment ) && !has_error && tuples.borked_rows .empty ();
1714+ auto scan_finder = make_uniq<StringValueScanner>(LINE_FINDER_ID, buffer_manager, state_machine_strict,
1715+ make_shared_ptr<CSVErrorHandler>(), csv_file_scan, false ,
1716+ current_iterator, result_size);
1717+ try {
1718+ auto &tuples = scan_finder->ParseChunk ();
1719+ current_iterator.pos = scan_finder->GetIteratorPosition ();
1720+ bool has_error = false ;
1721+ if (tuples.current_errors .HasError ()) {
1722+ if (tuples.current_errors .Size () != 1 || !tuples.current_errors .HasErrorType (MAXIMUM_LINE_SIZE)) {
1723+ // We ignore maximum line size errors
1724+ has_error = true ;
1725+ }
1726+ }
1727+ return (tuples.number_of_rows == 1 || tuples.first_line_is_comment ) && !has_error && tuples.borked_rows .empty ();
1728+ } catch (const Exception &e) {
1729+ return false ;
1730+ }
1731+ return true ;
17261732}
17271733
17281734ValidRowInfo StringValueScanner::TryRow (CSVState state, idx_t start_pos, idx_t end_pos) const {
0 commit comments