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

basedosdados::read_sql() - Erro: ! ProjectId and DatasetId must be non-empty [badRequest] #1704

Open
writing-versioncontrol opened this issue Feb 14, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@writing-versioncontrol
Copy link

Descrição
Tentando baixar dados, usando exemplo da documentação basedosdados::read_sql().

Da errado:
Error in signal_reason():
! ProjectId and DatasetId must be non-empty [badRequest]

Reproduzir
Passos para reproduzir o comportamento:

basedosdados::set_billing_id("br_census_sum_stats")
query <- "SELECT
pib.id_municipio,
pop.ano,
pib.PIB / pop.populacao * 1000 as pib_per_capita
FROM basedosdados.br_ibge_pib.municipio as pib
JOIN basedosdados.br_ibge_populacao.municipio as pop
ON pib.id_municipio = pop.id_municipio
LIMIT 5 "
data <- basedosdados::read_sql(query, billing_project_id = "br_census_sum_stats")
Error in signal_reason():
! ProjectId and DatasetId must be non-empty [badRequest]
Run rlang::last_trace() to see where the error occurred.

Backtrace:

  1. ├─basedosdados::read_sql(query)
  2. │ ├─... %>% bigrquery::bq_table_download(bigint = "integer64")
  3. │ └─bigrquery::bq_project_query(billing_project_id, query = query)
  4. │ └─bigrquery::bq_perform_query(...)
  5. │ └─bigrquery:::bq_post(url, body = bq_body(body, ...), query = list(fields = "jobReference"))
  6. │ └─bigrquery:::process_request(req)
  7. │ └─bigrquery:::bq_check_response(status, type, content)
  8. │ └─bigrquery:::signal_reason(json$error$errors[[1L]]$reason, json$error$message)
  9. └─bigrquery::bq_table_download(., bigint = "integer64")
  10. └─bigrquery::as_bq_table(x)

Comportamento esperado
Baixar o data set.

Capturas de tela
erro1

Desktop (preencha as seguintes informações):

sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8 LC_CTYPE=Portuguese_Brazil.utf8 LC_MONETARY=Portuguese_Brazil.utf8
[4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.utf8

time zone: America/Sao_Paulo
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] bit64_4.0.5 bit_4.0.5 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2
[7] purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2 tidyverse_2.0.0
[13] DescTools_0.99.52

loaded via a namespace (and not attached):
[1] gld_2.6.6 gtable_0.3.3 dotenv_1.0.3 gargle_1.5.0 lattice_0.21-8 tzdb_0.4.0
[7] vctrs_0.6.2 tools_4.3.0 generics_0.1.3 curl_5.0.1 proxy_0.4-27 fansi_1.0.4
[13] pkgconfig_2.0.3 Matrix_1.6-1.1 data.table_1.14.8 dbplyr_2.3.2 readxl_1.4.2 assertthat_0.2.1
[19] lifecycle_1.0.3 rootSolve_1.8.2.4 compiler_4.3.0 Exact_3.2 munsell_0.5.0 bigrquery_1.4.2
[25] httpuv_1.6.11 class_7.3-21 crayon_1.5.2 later_1.3.1 pillar_1.9.0 MASS_7.3-58.4
[31] openssl_2.0.6 boot_1.3-28.1 tidyselect_1.2.0 mvtnorm_1.2-4 stringi_1.7.12 rprojroot_2.0.3
[37] grid_4.3.0 here_1.0.1 colorspace_2.1-0 lmom_3.0 expm_0.999-9 cli_3.6.1
[43] magrittr_2.0.3 utf8_1.2.3 e1071_1.7-13 withr_2.5.0 promises_1.2.0.1 rappdirs_0.3.3
[49] scales_1.2.1 writexl_1.4.2 timechange_0.2.0 httr_1.4.6 basedosdados_0.2.2 typed_0.0.1
[55] cellranger_1.1.0 askpass_1.1 hms_1.1.3 rlang_1.1.1 Rcpp_1.0.10 glue_1.6.2
[61] DBI_1.1.3 rstudioapi_0.14 jsonlite_1.8.7 R6_2.5.1 fs_1.6.2

@gustavoalcantara
Copy link
Contributor

roda o basedosdados::read_sql sem o billing_id. somente a query. Além disso, verifica a inserção/remoção das aspas. Veja esse exemplo que talvez possa te ajudar: https://github.com/basedosdados/analises/blob/main/redes_sociais/br_ibge_censo_agropecuario_20220602.R

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants