From c23d816003d1107b73cd283740cdd9a56ad4047a Mon Sep 17 00:00:00 2001 From: "Jarod G.R. Meng" Date: Mon, 6 Nov 2023 20:19:51 +0800 Subject: [PATCH] Fix nested CTE leading to nested WITH problem --- NEWS.md | 2 ++ R/dbplyr-src.R | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 7d0e481..7e91ce3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # RPresto 1.4.6.9000 +* Fixed a bug whereby nested CTEs result in nested WITH. (#261) + # RPresto 1.4.6 * `tidyr::fill()` now works with PrestoConnection. (#233, thanks to @copernican diff --git a/R/dbplyr-src.R b/R/dbplyr-src.R index 3fd676b..840538c 100644 --- a/R/dbplyr-src.R +++ b/R/dbplyr-src.R @@ -253,8 +253,12 @@ copy_to.PrestoConnection <- function(dest, df, name = deparse(substitute(df)), o ) } con <- dbplyr::remote_con(x) + # We need to speicify sql_options here so that use_presto_cte is passed to + # db_sql_render correctly + # (see https://github.com/tidyverse/dbplyr/issues/1394) sql <- dbplyr::db_sql_render( - dbplyr::remote_con(x), x, use_presto_cte = FALSE + con = dbplyr::remote_con(x), sql = x, + sql_options = dbplyr::sql_options(), use_presto_cte = FALSE ) con@session$addCTE(name, sql, replace = TRUE) } else {