Given the full relationships data.frame returned by sq_sql_mine,
finds every script that references a given table and describes the role the
table plays in each relationship.
Arguments
- relationships
A data.frame as returned by
sq_sql_mine.- table_name
The table name to look up (a single string, matched case-insensitively against both
source_tableandtarget_table).
Value
A data.frame with columns:
- script_name
The script that references the table.
- role
"source"when the table appears in a FROM clause,"join_target"when it is the target of a JOIN, or"insert_target"when it is the destination of an INSERT.
One row per unique script_name / role combination. Returns a
zero-row data.frame (with the correct columns) if the table is not found.
Examples
if (FALSE) { # \dontrun{
scripts <- sq_read_sql_files("path/to/sql")
relationships <- sq_sql_mine(scripts)
sq_table_usage(relationships, "dbo.patients")
} # }