Skip to contents

Schemas group the tables of a lake, and are the natural home for medallion layers (bronze, silver, gold) or per-study areas. Every function that takes a table name accepts "schema.table", and list_ducklake_tables() shows each table's schema. DuckLake writes a schema's data files under a directory of their own, which is what path-based access control on object storage keys on.

Usage

create_schema(schema_name, if_not_exists = TRUE, ducklake_name = NULL)

Arguments

schema_name

Name of the schema.

if_not_exists

When the schema already exists, say so and do nothing (default TRUE) rather than error.

ducklake_name

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

Value

Invisibly, NULL.

Examples

lake_dir <- tempfile("schema_lake_")
dir.create(lake_dir)
attach_ducklake("schema_lake", lake_path = lake_dir)

# One schema per medallion layer
create_schema("bronze")
#> Created schema "bronze".
create_schema("silver")
#> Created schema "silver".

create_table(mtcars, "bronze.cars")
get_ducklake_table("bronze.cars") |>
  dplyr::filter(cyl == 4) |>
  create_table("silver.cars")

list_ducklake_tables()
#>   schema_name table_name  type
#> 1      bronze       cars table
#> 2      silver       cars table

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