I work in an rmarkdown / quarto document querying a database (Exasol) with read-only access. This works fine if executed in an R chunk as follows.
```{r}
conn <- exasol::dbConnect( drv = "exa", exahost = "my_host_url",
uid = Sys.getenv("EXASOL_USER"), pwd = Sys.getenv("EXASOL_PWD") )
query <- "SELECT * FROM MY_SCHEMA.MY_TABLE LIMIT 10"
df <- exasol::dbGetQuery(conn, query)
```
Now, I try to run the same query in an sql
chunk.
```{sql connection=conn}
SELECT * FROM MY_SCHEMA.MY_TABLE LIMIT 10
```
However, I get the following error message.
Using Schema from statement: "MY_SCHEMA"
Transaction rolled back.
Error in exa.readData(res$connection, query, ...) :
Could not receive header
In addition: Warning message:
In .EXAExecStatement(con = conn, stmt = statement, schema = schema, :
42500 -6818256 [EXASOL][EXASolution driver]insufficient privileges for creating table (Session: 1741969101333790720)[RODBC] ERROR: Could not SQLExecDirect 'create table "SUS_ANALYTICS".TEMP_791648_CREATED_BY_R as (SELECT * FROM MY_SCHEMA.MY_TABLE LIMIT 10
)'
Error in exa.readData(res$connection, query, ...) :
Could not execute SQL: '42000' -6811776' [EXASOL][EXASolution driver]object "MY_SCHEMA"."TEMP_791648_CREATED_BY_R" not found [line 1, column 23] (Session: 1741969101333790720)'
Failed to execute SQL chunk
I have read access only. So, the crucial information appears to be insufficient privileges for creating table
. It appears the engine tries to create a temporary table and fails.
- Why does this happen as the R chunk works without these problems?
- And, more important: Is there a way to make the sql chunk work? :)
PS. Sorry, I do not know how to make this example reproducible.