1

I am trying to make a code in Rstudio in order to run a code that is in a path in my PC, but there is an error that I can't fix. here is my code and the error:

>library(DBI)
>library(bigrquery)

>con <- dbConnect(odbc::odbc(), "Google Big Query", timeout = 10)

>sql_file <- readr::read_file("G:/Unidades compartidas/Afluenta Risk & Pricing/Risk/TIR/Cosechas/flujo_de_pagos_ar.sql")
>query <- bigrquery::bq_project_query("ar-enviroment-bu-risk", sql_file)

Running job 'ar-enviroment-bu-risk.job_iDk3x9tJidZY6Td3Sxknq9ywf6SP.US' [|] 33s
Complete
Billed: 216.01 MB
Error in UseMethod("as_bq_table") : 
  no applicable method for 'as_bq_table' applied to an object of class "NULL"

My code run perfectly in the BQ ennvironment. And when I run this code in Rstudio, then I review in BQ if it was completed and indees it was, so I dont know why this error happens

Can someone help me please?... thanks in advance

Phil
  • 7,287
  • 3
  • 36
  • 66

1 Answers1

0

The error message suggests your SQL query returns NULL instead of table rows. Thus R can not convert that NULL value into a data frame. That is a common error message for R connectors to many other data sources. Often caused by bad DB credentials.

It is hard to infer more than that without looking at the SQL and table you are querying.

  • But why run in the BQ environment good but in R also runs but throws the error even if the query was completed – Juan David Ossa Gomez Jul 05 '23 at 16:38
  • Yes, that might be counter intuitive. The problem is that connectors do not provide you with all the information about possible errors or warnings because they are designed for downloading data, not for debugging. Are you able to get the list of tables with the dbListTables(con) functions? – Oleg Solovyev Jul 06 '23 at 10:40