sqltargets icon indicating copy to clipboard operation
sqltargets copied to clipboard

tar_sql path parameter to depend on previous steps

Open kiwiroy opened this issue 1 month ago • 1 comments

I'm looking to achieve something like the following:

list(
  tar_sql(
    max_migration_version_str,
    path = here::here("sql", "get_migration_version.sql")
  ),
  tar_sql(
    dataset,
    path = here::here("sql", max_migration_version_str, "extract_dataset.sql")
  ),
  ...
)

This requires the path to become a dependent of basename(path) within another tar_target since it itself depends on max_migration_version_str.

kiwiroy avatar Nov 18 '25 20:11 kiwiroy

Hmmm, does the second path already exist at runtime? Or is it created during? Without testing I think you'd have to do something like:

list(
  tar_sql(
    max_migration_version_str,
    path = here::here("sql", "get_migration_version.sql")
  ),
  tarchetypes::tar_file(
    extract_dataset_query,
    fs::path(here::here(), "sql", max_migration_version_str, "extract_dataset.sql")
  )
  tar_sql(
    dataset,
    path = extract_dataset_query
  ),
  ...
)

daranzolin avatar Nov 20 '25 00:11 daranzolin