Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

29 lines
872B

  1. cf_db_create <- function(data_dir = here::here("data")) {
  2. tables <- dir_ls(data_dir)
  3. names(tables) <- path_file(tables)
  4. idx_report_list <- which(names(tables) == "report_list")
  5. cli::cli_progress_bar(name = "Opening parquet files", total = length(tables))
  6. env <- rlang::current_env()
  7. tbls_arrow <- tables[-idx_report_list] |>
  8. imap(function(path, name) {
  9. cli::cli_progress_update(inc = 1, status = name, .envir = env)
  10. arrow::open_dataset(path, partitioning = "sboe_id")
  11. })
  12. cli::cli_progress_update(inc = 1, status = "report_list")
  13. tbls_arrow$report_list <- arrow::open_dataset(tables["report_list"])
  14. cli::cli_progress_done()
  15. con <- DBI::dbConnect(duckdb::duckdb())
  16. cli::cli_progress_step("Creating db")
  17. imap(tbls_arrow, function(df, name) {
  18. duckdb::duckdb_register_arrow(con, name, df)
  19. dplyr::tbl(con, name)
  20. })
  21. }