pitrou commented on a change in pull request #11892:
URL: https://github.com/apache/arrow/pull/11892#discussion_r764762662



##########
File path: r/tests/testthat/test-csv.R
##########
@@ -447,5 +447,13 @@ test_that("write_csv_arrow deals with duplication in 
include_headers/col_names",
   )
   expect_true(file.exists(csv_file))
   expect_identical(tbl_no_dates, written_tbl)
+})
+
+test_that("read_csv_arrow() deals with BOMs (bite-order-marks) correctly", {

Review comment:
       "byte"

##########
File path: r/tests/testthat/test-dataset-csv.R
##########
@@ -288,3 +289,12 @@ test_that("Column names inferred from schema for 
headerless CSVs (ARROW-14063)",
   ds <- open_dataset(headerless_csv_dir, format = "csv", schema = schema(int = 
int32(), dbl = float64()))
   expect_equal(ds %>% collect(), tbl)
 })
+
+test_that("open_dataset() deals with BOMs (bite-order-marks) correctly", {

Review comment:
       "byte"

##########
File path: cpp/src/arrow/dataset/file_csv.cc
##########
@@ -85,7 +86,13 @@ Result<std::unordered_set<std::string>> GetColumnNames(
 
   RETURN_NOT_OK(
       parser.VisitLastRow([&](const uint8_t* data, uint32_t size, bool quoted) 
-> Status {
-        util::string_view view{reinterpret_cast<const char*>(data), size};
+        // Skip BOM when reading column names (ARROW-14644)
+        ARROW_ASSIGN_OR_RAISE(auto data_no_bom, util::SkipUTF8BOM(data, size));
+        ptrdiff_t offset = data_no_bom - data;
+        DCHECK_GE(offset, 0);

Review comment:
       This doesn't seem useful. You can therefore shorten this to:
   ```c++
           size = size - static_cast<uint32_t>(data_no_bom - data);
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to