Skip to contents

These object-aware helpers sit above fabric_onelake_download() and fabric_onelake_upload(). They serialize data frames, tibbles, and lazy Arrow inputs without collecting the complete object in R memory, and decode supported OneLake files directly to a tibble or Arrow stream.

Usage

fabric_onelake_read_file(
  workspace,
  item = NULL,
  path = "",
  format = c("auto", "parquet", "csv", "arrow"),
  result = c("tibble", "arrow_stream"),
  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(),
  dfs_base = "https://onelake.dfs.fabric.microsoft.com",
  col_names = TRUE,
  na = c("", "NA")
)

fabric_onelake_write_file(
  workspace,
  item = NULL,
  path = "",
  data,
  format = c("auto", "parquet", "csv", "arrow"),
  overwrite = FALSE,
  if_match = NULL,
  compression = "snappy",
  include_header = TRUE,
  na = "",
  create_parents = TRUE,
  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(),
  dfs_base = "https://onelake.dfs.fabric.microsoft.com",
  allow_managed_tables = FALSE,
  chunk_size = getOption("fabricqueryr.onelake.chunk_size", 8 * 1024^2)
)

Arguments

workspace

Workspace name, ID, object from fabric_workspaces(), or a complete OneLake HTTPS/ABFSS path.

item

Item name, GUID, or discovered Fabric item. Use NULL when workspace is a complete OneLake path.

path

Item-relative path, normally below Files/.

format

File format. "auto" infers "parquet", "csv", or "arrow" from the path extension.

result

Return a "tibble" or a disk-backed, single-use "arrow_stream". Tibbles preserve decimals as character strings. Signed 64-bit integers use bit64::integer64, or character if the column contains the minimum signed value (reserved for missing values by bit64). Int32 columns containing -2147483648 use exact R doubles. Nested lists retain character 64-bit integers and decimals, and double 32-bit integers.

item_type

Optional Fabric item type used to resolve a named item.

tenant_id

Entra tenant ID. Defaults to FABRICQUERYR_TENANT_ID.

client_id

Entra application ID. Defaults to FABRICQUERYR_CLIENT_ID, then the Azure CLI application ID.

token

Optional access token or audience-aware token-provider function.

auth_args

Additional sign-in options passed to AzureAuth::get_azure_token().

dfs_base

OneLake DFS service address. A private or regional endpoint on a discovered object is preferred when this argument is omitted.

col_names

Whether a CSV has a header, or a character vector of column names. Use FALSE for files written with include_header = FALSE.

na

Text used for missing values in a written CSV, or character values interpreted as missing when reading CSV.

data

A data frame, tibble, Arrow Table/RecordBatch, lazy Arrow Dataset/Scanner/query, RecordBatchReader, or Arrow-compatible array stream.

overwrite

Whether an existing OneLake file may be replaced.

if_match

Optional destination ETag for conditional replacement.

compression

Parquet compression codec passed to Arrow.

include_header

Whether a written CSV includes column names.

create_parents

Whether missing parent directories are created.

allow_managed_tables

Whether direct writes below Tables/ are permitted. Keep the safe default, FALSE, for managed Delta tables.

chunk_size

Upload chunk size in bytes.

Value

fabric_onelake_read_file() returns a tibble or a disk-backed nanoarrow_array_stream. fabric_onelake_write_file() returns OneLake metadata with additional format, rows, and columns fields.

Examples

if (FALSE) { # \dontrun{
# Discover the Lakehouse that will store the Parquet file
workspace <- fabric_workspaces()[[1L]]
lakehouse <- fabric_lakehouses(workspace)[[1L]]

# Serialize the R data frame directly to OneLake as Parquet
fabric_onelake_write_file(
  workspace,
  lakehouse,
  "Files/exports/orders.parquet",
  data.frame(id = 1:3, amount = c(10.5, NA, 30))
)

# Read the same file back as a tibble
orders <- fabric_onelake_read_file(
  workspace,
  lakehouse,
  "Files/exports/orders.parquet"
)
} # }