Read a Delta table from OneLake
Source:R/fabric_onelake_read_delta_table.R
fabric_onelake_read_delta_table.RdLoads a Lakehouse or compatible Warehouse table into R. By default the result is a tibble; you can select columns, preview a limited number of rows, read an earlier table version, or return an Arrow stream for larger results
Usage
fabric_onelake_read_delta_table(
table_path,
workspace_name,
lakehouse_name,
schema = NULL,
item_type = NULL,
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(),
version = NULL,
verbose = TRUE,
dfs_base = "https://onelake.dfs.fabric.microsoft.com",
columns = NULL,
limit = NULL,
result = c("tibble", "arrow_stream")
)Arguments
- table_path
Table name. Supply its schema separately when needed
- workspace_name
Workspace name, ID, or an object returned by
fabric_workspaces()- lakehouse_name
Lakehouse name, ID, or discovery object. Compatible Warehouse and mirrored database items are also accepted
- schema
Schema containing the table, or
NULL. Warehouses and mirrored databases default to"dbo"when discovery provides no default. Use""for a physical table directly belowTables/without a schema directory- item_type
"Lakehouse","Warehouse","MirroredDatabase", orNULL. Usually inferred; specify it only when using an item name without a type suffix- 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. Most users can leave this as
NULLand let 'fabricQueryR' sign in- auth_args
Extra sign-in options passed to
AzureAuth::get_azure_token()- version
Specific table version to read, or
NULLfor the latest- verbose
Whether to show authentication and read progress
- dfs_base
OneLake service address. Most users should keep the default; a workspace-specific address discovered from Fabric is used when available
- columns
Column names to return, or
NULLfor all columns- limit
Maximum number of rows to return, or
NULLfor all rows- result
"tibble"(the default) or"arrow_stream"for batch processing
Value
A tibble, or a disk-backed, lazy, single-use Arrow stream when
result = "arrow_stream". Explicitly release that stream, or close an
'arrow' reader that takes ownership of it, to delete its temporary file
Basic use
Supply the table name, workspace, and Lakehouse. Names, IDs, and discovery records are accepted. If the Lakehouse uses schemas, pass the schema name separately. The function otherwise reads the latest version and all columns and rows into a tibble
Use columns to keep only the fields you need, limit for a quick preview,
and version to read an earlier version. A row limit does not guarantee
which rows are selected
Large and nested results
For a large table, or one containing nested data, set
result = "arrow_stream" to process rows in batches instead of collecting
them all into R memory. The stream is disk-backed and can be read only once,
so enough temporary disk space must be available for the selected data.
Release the stream deterministically when finished: call
stream[["release"]]() when using 'nanoarrow' directly, or call
reader$Close() after arrow::as_record_batch_reader(stream). Do not rely
on garbage collection to delete the staged file, particularly on Windows
Column types
Common dates, timestamps, numbers, text, and logical values are converted to practical R types. Values that R cannot represent exactly, including decimal and 64-bit integer values, are returned as character data when collecting a tibble. Nested columns require an Arrow stream. The complete mapping is:
| Delta/Arrow source | Arrow stream result | Tibble result |
| Decimal (any precision/scale) | UTF-8 text | character |
| Large UTF-8 / large binary | original large-offset type | character / blob list-column |
| UTF-8 / binary views | UTF-8 / binary with 32-bit offsets | character / blob list-column |
| List views / large-list views | list / large list | rejected as nested |
| Large list | original large-offset list | rejected as nested |
| Signed/unsigned 64-bit integer | original integer type | exact character |
| Signed 32-bit integer | original integer type | double |
| Timestamp without timezone | original Arrow timestamp | character |
| Timestamp with timezone | original Arrow timestamp | UTC POSIXct |
| Date, Boolean, floating point, smaller integers, UTF-8, binary | corresponding Arrow scalar | corresponding R scalar type from 'nanoarrow' |
| Struct, map, list, extension/Variant | corresponding normalized Arrow type when supported | rejected; request an Arrow stream |
Decimal text retains its scale and digits. Arrow view types are normalized for R compatibility; ordinary large-offset types retain their offsets
Permissions and supported tables
Direct reads require OneLake data access; item Read permission by itself is
not enough. The caller needs ReadAll or a suitable OneLake security role,
and the tenant setting for external OneLake apps must be enabled. Callers
restricted by row- or column-level security must use a supported Fabric
engine instead. See the
Fabric permission model
and OneLake tenant settings
This function uses the Python
deltalake reader through 'reticulate'
Some newer Delta features, including Type Widening, V2 Checkpoints, and
shredded Fabric Variant, are not supported by that reader. The reader can
query an unshredded Variant table only when columns explicitly excludes
every top-level column containing Variant values. It otherwise returns
Variant's physical binary storage instead of decoded logical values, so this
function rejects that projection. Use SQL or Spark (Livy) for Variant values
or when the function reports another unsupported table feature
Compatible Warehouse tables can also be read through their published Delta
logs. If the reader cannot open a Warehouse table, use fabric_sql_query()
Examples
if (FALSE) { # \dontrun{
# Discover a Lakehouse and one of its Delta tables
workspace <- fabric_workspaces()[[1L]]
lakehouse <- fabric_lakehouses(workspace)[[1L]]
tables <- fabric_lakehouse_tables(lakehouse)
table <- tables[1L, ]
# Read the discovered table into a tibble
rows <- fabric_lakehouse_read_table(
lakehouse = lakehouse,
table = table
)
# Stream the same table when it may not fit in R memory
stream <- fabric_lakehouse_read_table(
lakehouse = lakehouse,
table = table,
result = "arrow_stream"
)
reader <- arrow::as_record_batch_reader(stream)
rows <- reader$read_table()
reader$Close()
} # }