From c5666c6e092b1a9d30d205e7cc168b060276123f Mon Sep 17 00:00:00 2001 From: pdet Date: Thu, 19 Dec 2024 14:17:33 +0100 Subject: [PATCH] Fix for issue #14648 --- data/csv/comments/14648.csv | 3 ++ .../csv_scanner/sniffer/csv_sniffer.cpp | 2 +- .../csv_scanner/sniffer/dialect_detection.cpp | 15 ++++---- test/sql/copy/csv/test_comment_midline.test | 36 ++++++++++++++++++- 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 data/csv/comments/14648.csv diff --git a/data/csv/comments/14648.csv b/data/csv/comments/14648.csv new file mode 100644 index 000000000000..2e8df271055e --- /dev/null +++ b/data/csv/comments/14648.csv @@ -0,0 +1,3 @@ +a,b +a#b +x,y \ No newline at end of file diff --git a/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp b/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp index 74928a5c730c..7d6e2e3ed4bc 100644 --- a/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +++ b/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp @@ -6,7 +6,7 @@ namespace duckdb { CSVSniffer::CSVSniffer(CSVReaderOptions &options_p, shared_ptr buffer_manager_p, CSVStateMachineCache &state_machine_cache_p, bool default_null_to_varchar_p) : state_machine_cache(state_machine_cache_p), options(options_p), buffer_manager(std::move(buffer_manager_p)), - default_null_to_varchar(default_null_to_varchar_p) { + lines_sniffed(0), default_null_to_varchar(default_null_to_varchar_p) { // Initialize Format Candidates for (const auto &format_template : format_template_candidates) { auto &logical_type = format_template.first; diff --git a/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp b/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp index ae06d024bad8..672859f8e21a 100644 --- a/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +++ b/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp @@ -80,11 +80,11 @@ string DialectCandidates::Print() { DialectCandidates::DialectCandidates(const CSVStateMachineOptions &options) { // assert that quotes escapes and rules have equal size - auto default_quote = GetDefaultQuote(); - auto default_escape = GetDefaultEscape(); - auto default_quote_rule = GetDefaultQuoteRule(); - auto default_delimiter = GetDefaultDelimiter(); - auto default_comment = GetDefaultComment(); + const auto default_quote = GetDefaultQuote(); + const auto default_escape = GetDefaultEscape(); + const auto default_quote_rule = GetDefaultQuoteRule(); + const auto default_delimiter = GetDefaultDelimiter(); + const auto default_comment = GetDefaultComment(); D_ASSERT(default_quote.size() == default_quote_rule.size() && default_quote_rule.size() == default_escape.size()); // fill the escapes @@ -187,6 +187,9 @@ void CSVSniffer::GenerateStateMachineSearchSpace(vector