You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/10/06 08:38:46 UTC

[GitHub] [arrow] thisisnic commented on a change in pull request #11327: ARROW-13624: [R] readr short type mapping has T and t backwards

thisisnic commented on a change in pull request #11327:
URL: https://github.com/apache/arrow/pull/11327#discussion_r723013132



##########
File path: r/tests/testthat/test-csv.R
##########
@@ -329,3 +330,32 @@ test_that("Write a CSV file with invalid batch size", {
     regexp = "batch_size not greater than 0"
   )
 })
+
+test_that("time mapping work as expected (ARROW-13624)", {
+  tbl <- tibble::tibble(
+    dt = as.POSIXct(c("2020-07-20 16:20", NA), tz = "UTC"),
+    time = c(hms::as_hms("16:20:00"), NA)
+  )
+  tf <- tempfile()
+  on.exit(unlink(tf))
+  write.csv(tbl, tf, row.names = FALSE)
+
+  df <- read_csv_arrow(tf,
+    col_names = c("dt", "time"),
+    col_types = "Tt",
+    skip = 1
+  )
+
+  expect_error(
+    read_csv_arrow(tf,
+      col_names = c("dt", "time"),
+      col_types = "tT", skip = 1
+    )
+  )

Review comment:
       > I think the error message comes from the C++ library
   
   Yep, that's right.  I've run locally and pasted below.  One of the ways you can tell it's from the C++ library is that it starts `Error: Invalid:`
   
   ``` Error: Invalid: In CSV column #1: CSV conversion error to timestamp[s]: invalid value '16:20:00'
   /home/nic2/arrow/cpp/src/arrow/csv/converter.cc:492  decoder_.Decode(data, size, quoted, &value)
   /home/nic2/arrow/cpp/src/arrow/csv/parser.h:123  status
   /home/nic2/arrow/cpp/src/arrow/csv/converter.cc:496  parser.VisitColumn(col_index, visit) 
   ```
   > The error message also references the CSV converter and parser using paths on my machine, so probably not useful to include as we would have to skip the test on CI.
   
   Technically, this wouldn't be a problem as we could just supply something like `regexp = "CSV conversion error to timestamp"` and not test for the full error.  However, as Neal says, it's a C++ error, so we probably don't want to test for it as the point here is testing the R package.  




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org