Iterates over a data.frame of SQL scripts (as returned by
sq_read_sql_files), parses each one, and returns a combined
data.frame of all table relationships found. Files that produce no
relationships emit a message and are skipped rather than causing an error.
Arguments
- scripts
A data.frame with at least columns
filenameandcontent, as returned bysq_read_sql_files.
Value
A data.frame with one row per table relationship and columns:
- script_name
File the relationship was extracted from.
- source_table
Primary read table (the FROM clause target).
- source_alias
Alias of the source table, or
NAif none.- source_is_cte
TRUEifsource_tableis a CTE defined in the same script.- target_table
JOIN target or INSERT write target.
- target_alias
Alias of the target table, or
NAif none.- target_is_cte
TRUEiftarget_tableis a CTE defined in the same script.- relationship_type
"JOIN"or"INSERT".- join_type
e.g.
"LEFT JOIN","INNER JOIN";NAfor INSERTs.- on_condition
The ON predicate string;
NAfor INSERTs.- depth
Integer depth relative to CTE nesting. Base tables = 1.
Examples
if (FALSE) { # \dontrun{
scripts <- sq_read_sql_files("path/to/sql/folder")
relationships <- sq_sql_mine(scripts)
} # }