Skip to content

Commit

Permalink
Merge pull request #3 from IoannaNika/revert-1-add_clock_functions
Browse files Browse the repository at this point in the history
correct difftime to match base r behavior
  • Loading branch information
IoannaNika authored Dec 10, 2024
2 parents e633470 + 08c74bf commit df43f0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
})

0 comments on commit df43f0f

Please sign in to comment.