Skip to content

Commit

Permalink
Add tests for if_else()
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisnic committed Jan 24, 2023
1 parent 8c7da3e commit 0662fae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/testthat/test-pkg-arrow.R
Expand Up @@ -632,3 +632,18 @@ test_that("arrow translation for is.na() works", {
)
)
})

test_that("arrow translation for if_else() works", {
skip_if_not(has_arrow_with_substrait())

expect_equal(
example_data[1:5, "dbl"] %>%
arrow_substrait_compiler() %>%
substrait_project(dbl, gt_five = if_else(dbl > 5, "over", "under")) %>%
dplyr::collect(),
tibble::tibble(
dbl = c(-999, -99, -9, 0, 9),
gt_five = c("under", "under", "under", "under", "over")
)
)
})
15 changes: 15 additions & 0 deletions tests/testthat/test-pkg-duckdb.R
Expand Up @@ -309,3 +309,18 @@ test_that("duckdb translation for >= works", {
tibble::tibble(dbl = c(0, 9))
)
})

test_that("duckdb translation for if_else() works", {
skip_if_not(has_duckdb_with_substrait())

expect_equal(
example_data[1:5, "dbl"] %>%
duckdb_substrait_compiler() %>%
substrait_project(dbl, gt_five = if_else(dbl > 5, "over", "under")) %>%
dplyr::collect(),
tibble::tibble(
dbl = c(-999, -99, -9, 0, 9),
gt_five = c("under", "under", "under", "under", "over")
)
)
})

0 comments on commit 0662fae

Please sign in to comment.