Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

Adds read_tbl_duckdb() to read tables from DuckDB database files, addressing the first item in #Column.

Changes

  • New function read_tbl_duckdb(): Attaches a DuckDB file (read-only) and reads the specified table as a duckplyr frame with lazy evaluation support
  • SQL injection prevention: Escapes paths (single quotes) and identifiers (double quotes)
  • Deterministic database aliasing: Uses rlang::hash() on normalized path to avoid re-attaching the same database

Usage

# Read a table from an external DuckDB file
df <- read_tbl_duckdb("data.duckdb", "my_table")

# Supports schema and prudence options
df <- read_tbl_duckdb("data.duckdb", "my_table", schema = "analytics", prudence = "lavish")

# Works with dplyr pipelines (lazy)
read_tbl_duckdb("data.duckdb", "users") %>%
  filter(active) %>%
  select(id, name)

The database remains attached for the session to support lazy evaluation of downstream operations.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cloud.r-project.org
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-echo --no-restore -e install.packages(&#34;devtools&#34;,~&#43;~repos=&#34;REDACTED&#34;) (dns block)
  • cran.rstudio.com
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArg--no-manualnextArg--no-build-vignettesnextArgduckplyr_1.1.3.9004.tar.gz (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArg--no-manualnextArg--no-build-vignettesnextArg--no-vignettesnextArgduckplyr_1.1.3.9004.tar.gz (dns block)
  • extensions.duckdb.org
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --slave --no-save --no-restore -f /tmp/Rtmp1c1AEr/callr-scr-2b7826470239 (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --slave --no-save --no-restore -f /tmp/Rtmpplycb5/callr-scr-3075710df2eb (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --slave --no-save --no-restore -f /tmp/RtmpOS8Mly/callr-scr-351f5cf19195 (dns block)
  • packagemanager.posit.co
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArg--no-manualnextArg--no-build-vignettesnextArgduckplyr_1.1.3.9004.tar.gz (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArg--no-manualnextArg--no-build-vignettesnextArg--no-vignettesnextArgduckplyr_1.1.3.9004.tar.gz (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add read_tbl_duckdb()</issue_title>
<issue_description>Read a table from an arbitrary database file.

  • read_tbl_duckdb() : should that function be able to read from an arbitrary DuckDB file? Alternative: read_db_duckdb()
  • db_attach() and db_detach() (similarly to db_exec())
  • compute(temporary = FALSE) checks if the target schema is provided and actually is attached to another database, errors otherwise
  • Should compute() accept a file name? Alternative: compute_db()</issue_description>

Comments on the Issue (you are @copilot in this section)

@krlmlr Descoping.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add read_tbl_duckdb function to read from database files Add read_tbl_duckdb() Nov 26, 2025
Copilot AI requested a review from krlmlr November 26, 2025 17:07
Copilot finished work on behalf of krlmlr November 26, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add read_tbl_duckdb()

2 participants