Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection pane duckdb schema identification error #6517

Closed
alearrigo opened this issue Feb 27, 2025 · 3 comments
Closed

Connection pane duckdb schema identification error #6517

alearrigo opened this issue Feb 27, 2025 · 3 comments
Assignees
Labels
area: connections Issues related to Connections category. bug Something isn't working lang: r support

Comments

@alearrigo
Copy link

alearrigo commented Feb 27, 2025

System details:

Positron and OS details:

Positron Version: 2025.02.0 (Universal) build 171
Code - OSS Version: 1.96.0
Commit: 55f7331
Date: 2025-02-10T16:03:19.797Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Darwin arm64 24.3.0

Interpreter details:

R 4.4.2

Describe the issue:

I created a new database with duckdb with two separate schemas. The code is reported below. I can see the tables I created in the connection pane, but there is no detail about the schema containing these tables. Moreover, I can only explore the table after switching to the correct schema. I'm doing something wrong or is this the expected behaviour?

EDIT: The same happens in Rstudio.

Steps to reproduce the issue:

library(DBI)
library(connections)
library(duckdb)
library(tidyverse)


db_file <- "~/Desktop/DB_TEST.duckdb"

con <- connection_open(duckdb(), db_file)


dbExecute(con, "CREATE SCHEMA IF NOT EXISTS SCHEMA_1;") # Create schema 1

dbExecute(con, "USE SCHEMA_1;") # switch to schema 1

dbWriteTable(con, "df1", mtcars) #write table

dbExecute(con, "CREATE SCHEMA IF NOT EXISTS SCHEMA_2;") # Create schema 2

dbExecute(con, "USE SCHEMA_2;") # switch to schema 2

dbWriteTable(con, "df2", iris) #write table

dbExecute(con, "USE main;") #switch to main

connection_close(con)

Image

Expected or desired behavior:

I expected the UI to show the table inside the corresponding schema and schema awareness when trying to open a table from the connection pane. That's how is represented in motherduck:

Image

Were there any error messages in the UI, Output panel, or Developer Tools console?

In the screenshot above.

@dfalbel dfalbel added area: connections Issues related to Connections category. lang: r labels Feb 27, 2025
@dfalbel
Copy link
Contributor

dfalbel commented Feb 27, 2025

Hi @alearrigo ,

Thanks for reporting! I believe this is an issue with the connections package: https://github.com/rstudio/connections since it also happens in RStudio. We should probably special case duckdb there, to make sure it works correctly with it.

@dfalbel
Copy link
Contributor

dfalbel commented Feb 28, 2025

@alearrigo I figured that duckdb has built-in support for the connections pane but it's not enabled by default. You need to set:

options("duckdb.enable_rstudio_connection_pane" = TRUE)
con <- DBI::dbConnect(duckdb(), db_file)

So you shouldn't need the connections package. However it has a bug that prevents it to work correctly. I have submitted a PR in: duckdb/duckdb-r#1063

@dfalbel
Copy link
Contributor

dfalbel commented Mar 6, 2025

Hi @alearrigo !

I opened rstudio/connections#19 to track the problem in the connections package, as there's no code change we can do in Positron to fix this issue.

I also sent a PR to duckdb-r: duckdb/duckdb-r#1063 which might make built-in support better.

@dfalbel dfalbel closed this as completed Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: connections Issues related to Connections category. bug Something isn't working lang: r support
Projects
None yet
Development

No branches or pull requests

3 participants