Skip to contents

Sets a DuckLake configuration option, either lake-wide or scoped to a schema or table. Options are persisted in the metadata catalog, so they survive detach/attach cycles and apply to every client of the lake.

Usage

set_ducklake_option(
  option,
  value,
  table_name = NULL,
  schema_name = NULL,
  ducklake_name = NULL
)

Arguments

option

Name of the option, e.g. "parquet_compression", "target_file_size", "sort_on_insert", or "data_inlining_row_limit". See https://ducklake.select/docs/stable/duckdb/usage/configuration for the full list.

value

The value to set. Logicals are rendered as true/false, numbers as numeric literals, and everything else as a quoted string.

table_name

Optional table name to scope the option to one table, optionally qualified as "schema.table".

schema_name

Optional schema name to scope the option to one schema (or, together with table_name, to qualify the table).

ducklake_name

Optional name of the attached DuckLake catalog. If NULL, the current database is used.

Value

Invisibly returns NULL.

Details

Table-scoped settings override schema-scoped ones, which override the lake-wide default. Runs CALL <lake>.set_option(...).

The options DuckLake 1.0 persists, with their defaults:

OptionDefaultWhat it controls
auto_compacttrueWhether maintenance calls made without a table argument include the table
data_inlining_row_limit10Rows below which an insert or delete is stored in the catalog instead of a file (see set_inlining_row_limit())
delete_older_thanunsetHow long a released file waits before cleanup_old_files() and checkpoints delete it
expire_older_thanunsetHow old a snapshot must be before checkpoints expire it
encryptedfalseEncrypt the Parquet files written to the data path (set at creation; see attach_ducklake(encrypted = ))
hive_file_patterntrueWrite partitioned data in Hive-style directories
parquet_compressionsnappyCodec: uncompressed, snappy, gzip, zstd, brotli, lz4, or lz4_raw
parquet_compression_level3Level for codecs that have one
parquet_row_group_size122880Rows per row group
parquet_row_group_size_bytesunsetBytes per row group, as an alternative to rows
parquet_version1Parquet format version, 1 or 2
per_thread_outputfalseOne output file per thread during a parallel insert
require_commit_messagefalseRefuse to commit a snapshot without a commit message
rewrite_delete_threshold0.95Deleted fraction of a file above which rewrite_data_files() rewrites it
sort_on_inserttrueSort inserted rows by the table's sort keys (see set_table_sorting())
target_file_size512MBTarget data file size for inserts and compaction
write_deletion_vectorsfalseWrite Iceberg V3 deletion vectors instead of positional delete files

created_by, data_path, and version also appear in get_ducklake_options() but describe the lake rather than configure it. Retention settings (expire_older_than, delete_older_than) take interval strings such as "90 days".

Examples

lake_dir <- tempfile("setopt_lake_")
dir.create(lake_dir)
attach_ducklake("setopt_lake", lake_path = lake_dir)
create_table(mtcars, "cars")

# Smaller files at some write cost, lake-wide
set_ducklake_option("parquet_compression", "zstd")
#> Option "parquet_compression" set to "zstd" for lake "setopt_lake".

# Skip one table during compaction
set_ducklake_option("auto_compact", FALSE, table_name = "cars")
#> Option "auto_compact" set to FALSE for table "cars".

# Make every snapshot carry a commit message (constrains later writes)
set_ducklake_option("require_commit_message", TRUE)
#> Option "require_commit_message" set to TRUE for lake "setopt_lake".

detach_ducklake("setopt_lake", shutdown = TRUE)
unlink(lake_dir, recursive = TRUE)