tests/testthat/test-io-parquet.R

test_that("Roundtrip to Parquet works", {
  df <- tibble(a = 1:3, b = letters[4:6])

  path_parquet <- withr::local_tempfile(fileext = ".parquet")

  df_to_parquet(df, path_parquet)
  out <- df_from_parquet(path_parquet)

  expect_equal(out, df)
})

test_that("Writing to Parquet works without materialization", {
  withr::local_options(duckdb.materialize_message = TRUE)

  df <- tibble(a = 1:3, b = letters[4:6])
  path_parquet <- withr::local_tempfile(fileext = ".parquet")

  df %>%
    as_duckplyr_df() %>%
    select(b, a) %>%
    df_to_parquet(path_parquet) %>%
    expect_silent()

  out <- df_from_parquet(path_parquet)
  expect_output(nrow(out))

  expect_equal(out, df[2:1])
})

Try the duckplyr package in your browser

Any scripts or data that you put into this service are public.

duckplyr documentation built on Sept. 12, 2024, 9:36 a.m.