From 08c74bf45e139246c1cf54e78010c2f73c4c9eec Mon Sep 17 00:00:00 2001 From: IoannaNika Date: Tue, 10 Dec 2024 15:07:20 +0100 Subject: [PATCH] correct difftime to match base r behaviour --- R/dplyr.R | 2 +- tests/testthat/test-dplyr.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/dplyr.R b/R/dplyr.R index 0e82a788..5188ec6b 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -366,7 +366,7 @@ sql_translation.BigQueryConnection <- function(x) { dbplyr:::check_unsupported_arg(tz) dbplyr:::check_unsupported_arg(units, allowed = "DAY") - dbplyr::build_sql("DATE_DIFF(CAST(", time2, " AS DATE), CAST(", time1, " AS DATE), DAY)") + dbplyr::build_sql("DATE_DIFF(CAST(", time1, " AS DATE), CAST(", time2, " AS DATE), DAY)") }, ), dbplyr::sql_translator(.parent = dbplyr::base_agg, diff --git a/tests/testthat/test-dplyr.R b/tests/testthat/test-dplyr.R index c1f8d7f2..05abc6da 100644 --- a/tests/testthat/test-dplyr.R +++ b/tests/testthat/test-dplyr.R @@ -291,5 +291,5 @@ test_that("difftime clock function translates to correct sql", { ) %>% dbplyr::sql_build(simulate_bigrquery()) - expect_equal(sql$select[[2]], "DATE_DIFF(CAST(`time2` AS DATE), CAST(`time1` AS DATE), DAY)") + expect_equal(sql$select[[2]], "DATE_DIFF(CAST(`time1` AS DATE), CAST(`time2` AS DATE), DAY)") })