Problem running a query in package "bigrquery" in R

179 Views Asked by At

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

1

There are 1 best solutions below

2
Oleg Solovyev On

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.