thisisnic commented on a change in pull request #9950: URL: https://github.com/apache/arrow/pull/9950#discussion_r611809776
########## File path: r/tests/testthat/test-json.R ########## @@ -86,6 +86,89 @@ test_that("read_json_arrow() supports col_select=", { expect_equal(names(tab2), c("hello", "world")) }) +test_that("read_json_arrow(schema=) with empty schema", { + tf <- tempfile() + writeLines(' + { "hello": 3.5, "world": 2, "third_col": 99} + { "hello": 3.25, "world": 5, "third_col": 98} + { "hello": 3.125, "world": 8, "third_col": 97 } + { "hello": 0.0, "world": 10, "third_col": 96} + ', tf) + + tab1 <- read_json_arrow(tf, schema = schema()) + + expect_identical( + tab1, + tibble::tibble( + hello = c(3.5, 3.25, 3.125, 0), + world = c(2L, 5L, 8L, 10L), + third_col = c(99L,98L,97L,96L) + ) + ) +}) + +test_that("read_json_arrow(schema=) with partial schema", { + tf <- tempfile() + writeLines(' + { "hello": 3.5, "world": 2, "third_col": 99} + { "hello": 3.25, "world": 5, "third_col": 98} + { "hello": 3.125, "world": 8, "third_col": 97 } + { "hello": 0.0, "world": 10, "third_col": 96} + ', tf) + + tab1 <- read_json_arrow(tf, schema = schema(third_col = float64(), world = float64())) + + print("input:") + print("schema:") + print(schema(third_col = float64(), world = float64())) + print(' + { "hello": 3.5, "world": 2, "third_col": 99} + { "hello": 3.25, "world": 5, "third_col": 98} + { "hello": 3.125, "world": 8, "third_col": 97 } + { "hello": 0.0, "world": 10, "third_col": 96} + ') + print("output:") + print(tab1) + Review comment: Yep, @jonkeane suggested I pop that in there to make it clear to whoever was reviewing what was happening as there was what looked like unusual behaviour when I was writing tests. @nealrichardson - to double check, is the column reordering mentioned in the comment at the very top expected behaviour? -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org