Problem with importing SQL BigQuery table into R. - Error in strsplit(name, ".", fixed = TRUE) : non-character argument

284 views Asked by At

I want to import SQL table from BigQuery (billing is anabled for this project), into my R Markdown code chunk. R version 4.3.0 (2023-04-21 ucrt) DBI version:1.1.3 Bigrquery version:1.4.2 dplyr version:2.4.0

install.packages(c("DBI", "dbplyr", "bigrquery"))  
library(bigrquery)
library(DBI)
library(dbplyr)

con <- dbConnect(
    bigrquery::bigquery(),
    project = "sunny-effort-399008",
    dataset = "Daily_tables",
    billing = "My_First_Project"
)
                    
dbListTables(con)
dbIsValid(con)

#METs table
met<- as.character("Mets")
METs<-tbl(con, "Mets")

After running this code yesterday, and today morning (until 13) I was able to obtain desired table. However now when I try to recall it I get:

Error in strsplit(name, ".", fixed = TRUE) : non-character argument 14. strsplit(name, ".", fixed = TRUE) 13. as_bq_table.BigQueryConnection(con, sql) 12. as_bq_table(con, sql) 11. db_query_fields.BigQueryConnection(con, ...) 10. dplyr::db_query_fields(con, ...) 9. eval_bare(expr((!!fun)(con, ...))) 8. dbplyr_fallback(con, "db_query_fields", ...) 7. dbplyr_query_fields(src$con, from) 6. vars %||% dbplyr_query_fields(src$con, from) 5. tbl_sql(c(subclass, "dbi"), src = src, from = from, ...) 4. tbl.src_dbi(dbplyr::src_dbi(src, auto_disconnect = FALSE), from = from, ...) 3. tbl(dbplyr::src_dbi(src, auto_disconnect = FALSE), from = from, ...) 2. tbl.DBIConnection(con, "Mets") 1. tbl(con, "Mets")

(I put whole Traceback) After importing "Mets" table from BigQuery this morning I was able to generate plots with its content until now. I have no idea what to do. Things I have tried:

  1. Checking the name of the table- 100% sure this is its name.
  2. Checking the connection with dbIsValid(con).
  3. Changing the "Mets" into a character name.
  4. Checked the presence of the "Mets" table in the source BigQuery project.
  5. Changed the table name which is being recalled for 3 different ones- none of them worked, and each resulted in the same output.

I run out of the ideas, also I looked through forums and could't found analogical problem. Here is one a bit similar :https://github.com/r-dbi/bigrquery/issues/492. But I have most recent version of dplyr (1.1.3), and it still does not work.

I have no idea how to reproduce this mistake, I am new to R (I'm sorry). If there is any information I can additionally add to help anyone to solve this problem I would love to supply it.

2

There are 2 answers

0
JerryWho On BEST ANSWER

I've got the same problem. I used dbplyr 2.4.0. My quick fix was going back to dbplyr version 2.3.4

3
Erin Asks On

As a work around to the function that is causing problems, this alternate way should get your table into R:

METs <- dbGetQuery(
  con, "SELECT * FROM sunny-effort-399008.Daily_tables.[table name here]")