Read a Microsoft Fabric Warehouse table
Source:R/fabric_warehouse_tables.R
fabric_warehouse_read_table.RdProvides the table-oriented read counterpart to
fabric_warehouse_write_table(). It resolves the Warehouse like the writer,
safely quotes the schema, table, and projected columns, and delegates query
execution and type conversion to fabric_sql_query(). Use that lower-level
function for filters, ordering, joins, aggregations, or other T-SQL.
Usage
fabric_warehouse_read_table(
warehouse,
table,
workspace = NULL,
schema = "dbo",
columns = NULL,
limit = NULL,
result = c("tibble", "arrow_stream"),
backend = c("odbc", "adbc"),
numeric_policy = c("auto", "exact", "driver"),
tenant_id = Sys.getenv("FABRICQUERYR_TENANT_ID"),
client_id = Sys.getenv("FABRICQUERYR_CLIENT_ID", unset =
"04b07795-8ddb-461a-bbee-02f9e1bf7b46"),
token = NULL,
auth_args = list(),
api_base = .fabric_api_base,
verbose = TRUE,
timeout = 30L,
max_tries = 3L,
retry_delay = 5,
sql_token = NULL
)Arguments
- warehouse
A Warehouse object returned by
fabric_warehouses()orfabric_item(), or its name or GUID whenworkspaceis supplied.- table
Warehouse table name, or a record containing a
name,table, ordisplayNamefield.- workspace
Workspace name, GUID, or discovery object containing
warehouse. May be omitted whenwarehouseis a discovery object.- schema
Warehouse schema. Defaults to
"dbo"; a table record can supply its schema when this argument is omitted.- columns
Optional unique column names to project.
- limit
Optional non-negative maximum number of rows to return.
- result
Return a
"tibble"for ordinary R analysis, or a single-use"arrow_stream". ADBC streams retain native Arrow types. ODBC streams are converted from R data frames and cannot recover values lost by the driver. The 'adbi' driver may fetch the complete result before returning the stream, so this option does not guarantee bounded-memory retrieval. An Arrow stream owns its DBI result and connection until the stream is released; consume it promptly or release it explicitly withnanoarrow::nanoarrow_pointer_release()- backend
SQL connection backend,
"odbc"or"adbc".- numeric_policy
"auto"(default) uses"driver"for ODBC and"exact"for ADBC. Automatic ODBC conversion warns once per R session about possible numeric precision loss. Set"driver"explicitly to accept the driver's conversions without this warning, or use"exact"to reject unsafe ODBC results before fetching"exact"preserves ADBC decimals as character and BIGINT asbit64::integer64, using character for columns containing the minimum BIGINT. INT columns containing-2147483648use exact doubles. Nested lists retain character decimals and 64-bit integers, and double 32-bit integers. Null struct parents requireresult = "arrow_stream"; exact tibble collection raisesfabric_arrow_null_struct_errorto preserve their distinction from valid structs with all-null fields. ODBC rejects DECIMAL, NUMERIC, INT and BIGINT columns before fetching: its conversion can round or truncate values or turn valid integer boundaries into missing values. Cast these columns tovarcharin SQL or use ADBC."driver"explicitly accepts the backend's conversions, including possible rounding and missing values, for either output format. This policy applies to this query helper; direct DBI calls onfabric_sql_connect()use the selected driver's conversion settings- tenant_id
Microsoft Entra tenant ID. Defaults to
FABRICQUERYR_TENANT_ID- client_id
Microsoft Entra application/client ID. Defaults to
FABRICQUERYR_CLIENT_ID, then the Azure CLI application ID- token
Optional access token or token-provider function. Leave
NULLto let 'fabricQueryR' use its normal sign-in flow- auth_args
Additional sign-in options passed to
AzureAuth::get_azure_token()- api_base
Fabric REST API base used when a Warehouse name or GUID must be discovered.
- verbose
Whether to report SQL connection progress.
- timeout
Non-negative whole-number login/connect timeout in seconds;
0lets the driver use an unlimited or driver-specific timeout- max_tries
Maximum attempts after temporary Fabric SQL failures
- retry_delay
Initial delay in seconds before retrying. Later retries wait progressively longer, up to 60 seconds
- sql_token
Optional separate Azure SQL token or token-provider function. Supply it when
tokenis fixed rather than audience-aware.
Large results
Use backend = "adbc" with result = "arrow_stream" for a native Arrow
result path that avoids conversion to an R data frame. The current result path
through 'DBI' and 'adbi' may fetch the complete result before returning the
stream, so use a selective query or limit when the result may exceed memory.
The external ADBC mssql driver must be installed.
limit uses T-SQL TOP and does not define row order. Use
fabric_sql_query() with an explicit ORDER BY when deterministic row
selection matters.
Examples
if (FALSE) { # \dontrun{
# Discover the Warehouse instead of copying its SQL connection details
workspace <- fabric_workspaces()[[1L]]
warehouse <- fabric_warehouses(workspace)[[1L]]
# Use 'DBI' metadata to discover an existing table in that Warehouse
con <- fabric_sql_connect(warehouse)
tables <- DBI::dbListTables(con)
DBI::dbDisconnect(con)
table <- tables[[1L]]
# Read a bounded selection into a tibble
orders <- fabric_warehouse_read_table(
warehouse,
table,
backend = "adbc",
limit = 1000
)
# Keep the result Arrow-native rather than converting it to a data frame
stream <- fabric_warehouse_read_table(
warehouse,
table,
backend = "adbc",
result = "arrow_stream"
)
reader <- arrow::as_record_batch_reader(stream)
} # }