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

dbplyr 2.4.0 - connecting to a table via a database link no longer works #1445

Closed
mgarbuzov opened this issue Feb 6, 2024 · 3 comments
Closed

Comments

@mgarbuzov
Copy link

This connection still works in 2.3.4, doesn't work since 2.4.0.

tbl(con, from = in_schema("MY_SCHEMA", sql("MY_TABLE@MY_DB_LINK")))
Error in `db_query_fields.DBIConnection()`:
! Can't query fields.
Caused by error:
! nanodbc/nanodbc.cpp:1710: 42S02
[Oracle][ODBC][Ora]ORA-00942: table or view does not exist
 
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `db_query_fields.DBIConnection()`:
! Can't query fields.
Caused by error:
! nanodbc/nanodbc.cpp:1710: 42S02
[Oracle][ODBC][Ora]ORA-00942: table or view does not exist
 
---
Backtrace:1. ├─dplyr::tbl(con, from = in_schema("MY_SCHEMA", sql("MY_TABLE@MY_DB_LINK")))
  2. └─dplyr:::tbl.DBIConnection(con, from = in_schema("MY_SCHEMA", sql("MY_TABLE@MY_DB_LINK")))
  3.   ├─dplyr::tbl(...)
  4.   └─dbplyr:::tbl.src_dbi(...)
  5.     └─dbplyr::tbl_sql(c(subclass, "dbi"), src = src, from = from, ...)
  6.       ├─vars %||% dbplyr_query_fields(src$con, from)
  7.       └─dbplyr:::dbplyr_query_fields(src$con, from)
  8.         └─dbplyr:::dbplyr_fallback(con, "db_query_fields", ...)
  9.           ├─rlang::eval_bare(expr((!!fun)(con, ...)))
 10.           └─dbplyr:::db_query_fields.DBIConnection(con, ...)
Run rlang::last_trace(drop = FALSE) to see 6 hidden frames.
@hadley
Copy link
Member

hadley commented Feb 14, 2024

What is a database link?

@mgarbuzov
Copy link
Author

mgarbuzov commented Feb 15, 2024

@hadley if you have two databases, you can set up a link between them. Then, when you're connected to Database A, you can query tables in Database B via the link by including table_name@link_name (see here). The problem is, I was able to do this in dbplyr 2.3.4 by wrapping the table name with the link in sql(), but it stopped working since 2.4.0.

Upd: not sure, but might be related to Issue #1388 since their query also wrapped table name in dbplyr::sql().

@hadley
Copy link
Member

hadley commented Feb 15, 2024

Yeah, looks like a duplicate of #1388, which I'm working on now.

@hadley hadley closed this as completed Feb 15, 2024
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

No branches or pull requests

2 participants