Skip to contents

This function deletes all data related to specified projects (or other metadata filters) from the data lake across the given layers. It first lists the matching objects using dl_ls(), displays the files to be deleted, and then prompts the user for confirmation before proceeding with the deletion.

Usage

dl_rm(
  entity = NULL,
  ...,
  layer = NULL,
  verbose = FALSE,
  prompt = TRUE,
  limit = Inf,
  project = dl_get_project(),
  env = "prod"
)

Arguments

entity

Optional character vector defining one or more entities (e.g. "data/srv_main"). If NULL, lists all entities.

...

Named tag arguments (tag = value).

  • wave A character vector specifying the waves to filter on.

  • type A character vector specifying the types to filter on.

  • name A character vector specifying the names to filter on.

  • version A character vector specifying the versions to filter on.

  • batch A character vector specifying the batches to filter on.

  • source A character vector specifying the sources to filter on.

layer

Optional character vector of layers (e.g. "data", "models"). If NULL, includes all layers.

verbose

Logical. If TRUE, prints informational messages. Default is TRUE.

prompt

Logical. If TRUE (the default), the user is prompted for confirmation before deletion proceeds.

limit

An integer specifying the maximum number of objects to delete. Default is Inf.

project

Character scalar or vector defining one or more projects. If omitted, inferred from DESCRIPTION. If NULL, lists across all projects.

env

Environment of the datalake to use ("prod" or "test"). Defaults to "prod". "prod" = g6tr-dl, "test" = g6tr-dl-test.

Value

This function returns tibble of deleted objects.

Details

The function first retrieves all matching objects from the S3 bucket "g6tr-datalake" using dl_ls() with the provided filters, including any extra filters passed via .... It then displays the list of objects (including their sizes, if available) and prompts the user for confirmation before deleting each object.

Examples

if (FALSE) { # \dontrun{
# Remove all data for project "project1" across all layers
dl_rm(project = "project1")

# Remove data for "project1" and "project2" from the "fzl" and "lzl" layers
dl_rm(project = c("project1", "project2"), layer = c("fzl", "lzl"))

# Remove objects with extra metadata region equal to "NA"
dl_rm(layer = "fzl", region = "NA")
} # }