nealrichardson commented on a change in pull request #11327:
URL: https://github.com/apache/arrow/pull/11327#discussion_r722403787
##########
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
+ )
+ )
+
+ expect_equal(
+ df,
+ tbl,
+ ignore_attr = TRUE
Review comment:
Do we need to ignore all attributes?
```suggestion
ignore_attr ="tzone"
```
##########
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:
Do we care to assert the error message here, or is it something from the
C++ library that we don't want to write a test for?
--
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]