From c892158a05d12ba3129a9f2b4077fe1033046abe Mon Sep 17 00:00:00 2001 From: Tmonster Date: Thu, 14 Sep 2023 13:08:32 +0200 Subject: [PATCH] add csv reading test for na.strings --- tests/testthat/test_read.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test_read.R b/tests/testthat/test_read.R index 0296d0ae5..c1da623ec 100644 --- a/tests/testthat/test_read.R +++ b/tests/testthat/test_read.R @@ -108,5 +108,16 @@ test_that("duckdb_read_csv() works as expected", { res$Species <- as.factor(res$Species) expect_true(identical(res, iris)) + # test better na.strings handling + # see https://github.com/duckdb/duckdb/issues/8590 + tf3 <- tempfile() + na_strings <- data.frame(num=c(1, 2, NA), char=c('yes', 'no', NA), logi=c(TRUE, FALSE, NA)) + write.csv(na_strings, tf3, row.names = FALSE) + duckdb_read_csv(con, "na_table", tf3, na.strings = "-") + identical( + dbReadTable(con, "na_table"), + read.csv(tf3, na.strings = "-") + ) + dbDisconnect(con, shutdown = TRUE) })