From 3beb7a5f5455b928d6c9f712e11c958b3fb651c5 Mon Sep 17 00:00:00 2001 From: Yoon-Min Nam Date: Fri, 30 Nov 2018 11:44:56 +0900 Subject: [PATCH] Fix CSV scanner for handling filter predicate on a VARCHAR column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CSV scan does not care about delimiter in a CSV file, but query processor should care the end of each column value, i.e., ‘\0’. Because query parser parses each selection predicate by adding ‘\0’ at the end of the predicate value, query processor cannot handle the query correctly if we ignore the existence of delimiter in a raw tuple in CSV file. This simple solution fix the case by replacing delimiter to ‘\0’, and thus StringCompare in type/type_util.h works correctly. --- src/codegen/util/csv_scanner.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/codegen/util/csv_scanner.cpp b/src/codegen/util/csv_scanner.cpp index 5f09349f973..62aaf28f855 100644 --- a/src/codegen/util/csv_scanner.cpp +++ b/src/codegen/util/csv_scanner.cpp @@ -362,6 +362,9 @@ void CSVScanner::ProduceCSV(char *line) { cols_[col_idx].len = static_cast(col_end - col_begin); cols_[col_idx].is_null = (cols_[col_idx].len == 0); + // Yoon-Min: replace delimiter to '\0' to fix a bug while comparing + // filter condition in a query and column value of VARCHAR type + *iter = 0; // Eat delimiter, moving to next column iter++; } @@ -372,4 +375,4 @@ void CSVScanner::ProduceCSV(char *line) { } // namespace util } // namespace codegen -} // namespace peloton \ No newline at end of file +} // namespace peloton