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

Oracle backend not treated correctly #1519

Open
DSLituiev opened this issue Jun 25, 2024 · 1 comment
Open

Oracle backend not treated correctly #1519

DSLituiev opened this issue Jun 25, 2024 · 1 comment

Comments

@DSLituiev
Copy link

DSLituiev commented Jun 25, 2024

The oracle backend does not get recognised (v. 2.5.0 and main branch @Head)

When I force backend to Oracle it works, but I am not sure how to force it in tbl statement:

drv <- JDBC("oracle.jdbc.driver.OracleDriver", "~/lib/instantclient_19_8/ojdbc8.jar")
conn <- dbConnect(drv, 
                  "jdbc:oracle:thin:@host:port/...",
                  user=credentials$user,
                  password=credentials$pwd
)

conn
# <JDBCConnection>
attr(conn, "jc")
# [1] "Java-Object{oracle.jdbc.driver.T4CConnection@...}"

dim_xyz <- tbl(conn, in_schema("MYSCHEMA", "DIM_XYZ"))

dim_xyz

Trying to print the table gets an error:

Error in `collect()`:
! Failed to collect lazy table.
Caused by error in `dbSendQuery()`:
! Unable to retrieve JDBC result set
  JDBC ERROR: ORA-00933: SQL command not properly ended

  Statement: SELECT "DIM_XYZ".*
FROM "MYSCHEMA"."DIM_XYZ"
LIMIT 11

Here are some attempts to get to why it does not use the proper backend:

dbplyr:::test_translate_sql(head, con=conn)
# <SQL> "head"
> dbplyr:::sql_query_select(conn, sql("*"), ident("x"), where=ident("y"), limit=3)
<SQL> SELECT *
FROM "x"
WHERE (y)
LIMIT 3


> dbplyr:::sql_query_select.Oracle(conn, sql("*"), ident("x"), where=ident("y"), limit=3)
<SQL> SELECT *
FROM "x"
WHERE (y)
FETCH FIRST 3 ROWS ONLY
mf <- lazy_frame(x = 1, con = simulate_oracle())
> mf %>% head()
<SQL>
SELECT `df`.*
FROM `df`
FETCH FIRST 6 ROWS ONLY
@DSLituiev
Copy link
Author

DSLituiev commented Jun 26, 2024

workaround: wrap the connection into a new S4 class with jc slot copied from the original connection object:

setClass("Oracle", slots=list(),
         contains = "JDBCConnection")
conn_fixed <- new("Oracle", jc = slot(conn, "jc"))

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

1 participant