-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Labels
Description
Getting error when running simple query in dplyr syntax with slice_sample
on bigquery sample data. I am able to query if I replicate using standard SQL and the RAND() function.
The error reads
Function not found: random; Did you mean rand? at [2:508]
Maybe need to update backend with a new function? Looks like the show_query
uses RANDOM
not RAND
.
library(tidyverse)
library(dbplyr)
library(bigrquery)
library(DBI)
# bigquery authentication
bq_auth(path = 'xxxx.json')
con <- dbConnect(
bigrquery::bigquery(),
project = "bigquery-public-data",
dataset = "samples",
billing = "billing"
)
# THIS WORKS
sql <- "SELECT *
FROM `publicdata.samples.natality`
WHERE RAND() < 0.001"
example <- dbGetQuery(con, sql2)
glimpse(example)
# THIS DOES NOT WORK
# use dbi/dplyr syntax
natality <- tbl(con, "natality")
nat <-
natality %>%
slice_sample(n=50) %>%
collect()