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

Error when writing a table to databricks with dbWriteTable() #904

Closed
emilianomm opened this issue Mar 12, 2025 · 3 comments
Closed

Error when writing a table to databricks with dbWriteTable() #904

emilianomm opened this issue Mar 12, 2025 · 3 comments

Comments

@emilianomm
Copy link

Hi

Trying to automatize the upload of excels files to databricks I encountered an error with dbWriteTable(). I'm using a code very much like this one

library(readxl)
library(DBI)
library(odbc)
library(dplyr)
library(janitor)

# Define the path to the Excel file
file1 <- read_excel("path/to/your/excel1.xlsx")
file2 <- read_excel("path/to/your/excel2.xlsx")

# Read the Excel file
df_final <- bind_rows(
  file1,
  file2
) %>%
  clean_names()

# Define the connection details
access_token <- "your_access_token_here"

# Create a connection string using JDBC
con <- dbConnect(
  odbc::databricks(),
  workspace = "your_workspace_url",
  httpPath = "your_http_path",
  uid = "token",
  pwd = access_token
)

# Error part
dbWriteTable(
  con,
  name = Id(schema = "your_schema", table = "your_table", catalog = "your_catalog"),
  value = df_final,
  append = TRUE
)

But the last R statement returns the following error

[UNBOUND_SQL_PARAMETER] Found the unbound parameter: _1980. Please, fix argsand provide a mapping of the parameter to either a SQL literal or collection constructor functions such asmap(), array(), struct(). SQLSTATE: 42P02; line 2 pos 8

Upon reviewing the monitoring tab on the sql warehouse (within databricks), it show the same error on the job history.

What may be causing this error?

Thanks

@viv-analytics
Copy link

Hi @emilianomm,

In the past, setting the option useNativeQuery = FALSE has been effective for me.
You may want to try the following code snippet to establish a connection:

con_db_odbc <- DBI::dbConnect(drv = odbc::databricks(), HTTPPath = Sys.getenv("HTTP_PATH"), useNativeQuery = FALSE)

I hope this information is helpful

@detule
Copy link
Collaborator

detule commented Mar 24, 2025

Thanks @emilianomm !

Closing this issue since this behavior is documented.

@detule detule closed this as completed Mar 24, 2025
@emilianomm
Copy link
Author

Appreciate

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

3 participants