Summarise the table dependencies of a single script
Source:R/sq_script_dependencies.R
sq_script_dependencies.RdGiven the full relationships data.frame returned by sq_sql_mine,
filters to one script and returns each distinct table it reads from or
writes to. CTE names are excluded because they are internal to the script
and do not represent external dependencies.
Arguments
- relationships
A data.frame as returned by
sq_sql_mine.- script_name
The
script_namevalue to summarise (a single string matching one of the values inrelationships$script_name).
Value
A data.frame with columns:
- table_name
The table being read from or written to.
- role
"reads"for source tables and JOIN targets;"writes"for INSERT targets.
One row per unique table_name / role combination. Returns a
zero-row data.frame (with the correct columns) if the script is not found
or has no qualifying relationships.
Examples
if (FALSE) { # \dontrun{
scripts <- sq_read_sql_files("path/to/sql")
relationships <- sq_sql_mine(scripts)
sq_script_dependencies(relationships, "my_etl.sql")
} # }