dbplyr icon indicating copy to clipboard operation
dbplyr copied to clipboard

Setting a seed for a query

Open kchou496 opened this issue 9 months ago • 0 comments

Hello, Trying to take a consistent sample from a Redshift database by setting a seed but none of the below methods have worked. Would appreciated some help or guidance on how to do so, thanks!

db_query <- db_tbl %>%
filter(rand() < 0.1) %>%
sql_render() %>%
paste("set seed to 0.5", .)
set.seed(123)
db_tbl %>%
filter(rand() < 0.1) %>%
tally

Have tried suggestions from these threads but have not worked. https://forum.posit.co/t/how-to-set-a-seed-for-dplyr-sql/167264 https://stackoverflow.com/questions/52848079/setting-a-seed-with-dbplyr

kchou496 avatar Jan 28 '25 14:01 kchou496