LadybugDB extensions from R

LadybugDB extensions add graph algorithms, indexes, and external data sources. The CRAN build intentionally excludes the engine’s native networking stack: lb_install_extension() and lb_update_extension() therefore report an unsupported-operation error. A compatible extension installed outside R can still be loaded with lb_load_extension(). The examples are not executed while this vignette is built.

library(rladybugdb)

db <- lb_database("extensions.lbug")
conn <- lb_connection(db)
on.exit({
  lb_close(conn)
  lb_close(db)
}, add = TRUE)

lb_list_extensions(conn)
lb_close(lb_load_extension(conn, "algo"))

The helpers validate official extension names. The CRAN build supports LOAD for compatible extension files installed outside R.

PageRank and Louvain

Algorithms run on a projected graph. Given Person nodes and KNOWS relationships:

lb_close(lb_execute(
  conn,
  "CALL project_graph('SocialGraph', ['Person'], ['KNOWS'])"
))

page_rank <- lb_query(
  conn,
  paste(
    "CALL page_rank('SocialGraph')",
    "RETURN node.name AS name, rank AS pagerank",
    "ORDER BY rank DESC"
  )
)

communities <- lb_query(
  conn,
  paste(
    "CALL louvain('SocialGraph')",
    "RETURN louvain_id, collect(node.name) AS members",
    "ORDER BY louvain_id"
  )
)

DuckDB, PostgreSQL, and SQLite

Install and load the corresponding extension, attach the external database, then scan its tables with LOAD FROM. Credentials and paths below are placeholders and must come from trusted configuration.

for (extension in c("duckdb", "postgres", "sqlite")) {
  lb_close(lb_load_extension(conn, extension))
}

lb_close(lb_execute(conn, "ATTACH 'warehouse.duckdb' AS wh (dbtype duckdb)"))
duck_rows <- lb_query(conn, "LOAD FROM wh.events RETURN * LIMIT 100")

lb_close(lb_execute(
  conn,
  "ATTACH 'host=localhost dbname=app' AS pg (dbtype postgres)"
))
postgres_rows <- lb_query(conn, "LOAD FROM pg.public.events RETURN * LIMIT 100")

lb_close(lb_execute(conn, "ATTACH 'app.sqlite' AS sq (dbtype sqlite)"))
sqlite_rows <- lb_query(conn, "LOAD FROM sq.events RETURN * LIMIT 100")

Parquet, Iceberg, and ADBC

Parquet can be scanned directly by the core import syntax. Iceberg and ADBC use extensions and expose their sources through the same LOAD FROM model.

parquet_rows <- lb_query(conn, "LOAD FROM 'events/*.parquet' RETURN *")

lb_close(lb_load_extension(conn, "iceberg"))
# Configure the catalog according to the LadybugDB Iceberg documentation,
# then scan the attached catalog.table with LOAD FROM.

lb_close(lb_load_extension(conn, "adbc"))
# Install the database vendor's ADBC driver, attach it using that driver's
# connection options, then query its tables with LOAD FROM.

Extension availability and parameters follow the installed LadybugDB engine. Use lb_list_extensions() and the upstream extension documentation as the source of truth for a deployment.