get_table.Rd
Get an arbitrary table from the data warehouse (more axccurate if database and schema are given)
get_table(.table_name, .server_name, .database_name, .schema, ...)
the name of a table as a quoted string that you'd like to obtain
the name of the server that hosts the database
the name of the database which hosts the table
the name of the schema that hosts the database
other arguments passed to get_table
(recursively); end user won't typcially use this
a tbl_sql SQL Server
object (or Null
if there is not unique table in the warehouse)
This is a workhouse function that provides direct access to any table we have in the warehouse.
If the table name uniquely defines that table then the function looks up the server, database, and schema
location and you'll get the table back; if more than one table is identified the function will
fail informatively, giving you the get_table
command to run for every option in the warehouse.
Note well that this function makes at least 2 database calls. The first is to look up the table location
and then second to get your data. This means that it will run slower than other get_*
functions in
this package the don't make the first call: those tables' locations are looked up on a static dateframe.
if (FALSE) {
# This won't return a table, but instead an informative error show all `Students`
# tables (20 as of this writing) in the warehouse
# The warning provides code that can be copied and pasted to get a given table.
students <- get_tables("Students")
# Trying again with a specific table in specific schema in a specific database
get_table(.table_name = "Students",
.database_name = "PROD1",
.schema = "Schools")
# And here's an example
}