Expected `identical(res_df, data.frame(a = 1:3))` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

test_that("parquet reader works on the notorious userdata1 file", {
res <- dbGetQuery(con, "SELECT * FROM parquet_scan('data/userdata1.parquet')")
test_that("parquet reader works with the binary as string flag", {
res <- dbGetQuery(con, "SELECT typeof(#1) FROM parquet_scan('data/binary_string.parquet',binary_as_string=true) limit 1")
test_that("duckdb_write_parquet() works as expected", {
df_rel <- rel_from_df(con, data.frame(a = 1:3))
res_rel <- rel_from_table_function(con, 'read_parquet', list(tf))
df_na <- data.frame(a = c(1:3, NA, 5:6))
test_that("duckdb rel_to_parquet() throws error with no file name", {
df_rel <- rel_from_df(con, data.frame(a = 1L))
test_that("duckdb rel_to_parquet() allows multiple files (#1015)", {
rel1 <- rel_from_df(con, data.frame(a = 1))
rel2 <- rel_from_df(con, data.frame(a = 2))
res_rel <- rel_from_table_function(con, "read_parquet", list(list(c(tf1, tf2))))
expect_identical(res_df, data.frame(a = c(1, 2)))

"parquet reader works on the notorious userdata1 file"
"parquet reader works with the binary as string flag"
"SELECT typeof(#1) FROM parquet_scan('data/binary_string.parquet',binary_as_string=true) limit 1"
"duckdb rel_to_parquet() throws error with no file name"
"duckdb rel_to_parquet() allows multiple files (#1015)"

Expected `identical(res_df, df_na)` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

Expected `res_df` to be identical to `data.frame(a = c(1, 2))`.
Differences:
  `attr(actual, 'row.names')`: NA -2
`attr(expected, 'row.names')`:  1  2

duckdb rel_to_parquet() allows multiple files (#1015)

Expected `out` to be identical to `data.frame(a = 1L, b = 2)`.
Differences:
  `attr(actual, 'row.names')`: NA -1
`attr(expected, 'row.names')`:  1

# Generated by duckplyr's 05-duckdb-tests.R, do not edit by hand
dbExecute(con, 'CREATE MACRO "___eq_na_matches_na"(x, y) AS (x IS NOT DISTINCT FROM y)')
tmp_expr <- expr_window(expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
expr_function("___eq_na_matches_na", list(expr_reference("a", rel5), expr_reference("a", rel4)))
rel7 <- rel_order(rel6, list(expr_reference("___row_number_x", rel5)))
expr_function("___eq_na_matches_na", list(expr_reference("a", rel2), expr_reference("a", rel4)))
rel6 <- rel_order(rel5, list(expr_reference("a"), expr_reference("b")))
rel3 <- rel_order(rel2, list(expr_reference("a"), expr_reference("___row_number")))
rel3 <- rel_order(rel2, list(expr_reference("g"), expr_reference("___row_number")))
test_that("relational arrange(g, a) order-preserving", {
test_that("relational arrange(a, g) order-preserving", {
test_that("relational arrange(g, a) order-enforcing", {
rel2 <- rel_order(rel1, list(expr_reference("g"), expr_reference("a")))
test_that("relational arrange(a, g) order-enforcing", {
rel2 <- rel_order(rel1, list(expr_reference("a"), expr_reference("g")))
invisible(dbExecute(con, 'CREATE MACRO "n"() AS CAST(COUNT(*) AS int32)'))
data.frame(a = seq(1, 6, by = 1), n = 1L)
test_that("relational count(g, a) order-preserving", {
test_that("relational count(b, g) order-preserving", {
rel4 <- rel_order(rel3, list(expr_reference("a"), expr_reference("n")))
rel4 <- rel_order(rel3, list(expr_reference("b"), expr_reference("n")))
rel4 <- rel_order(rel3, list(expr_reference("g"), expr_reference("n")))
test_that("relational count(g, a) order-enforcing", {
test_that("relational count(b, g) order-enforcing", {
test_that("relational distinct(a, b) order-preserving", {
data.frame(a = seq(1, 6, by = 1), b = 2)
test_that("relational distinct(b, b) order-preserving", {
test_that("relational union_all(data.frame(a = 1L, b = 3, g = 2L)) %>% distinct(g) order-preserving", {
df2 <- data.frame(a = 1L, b = 3, g = 2L)
test_that("relational union_all(data.frame(a = 1L, b = 4, g = 2L)) %>% distinct(g) order-preserving", {
df2 <- data.frame(a = 1L, b = 4, g = 2L)
test_that("relational union_all(data.frame(a = 1L, b = 5, g = 2L)) %>% distinct(g) order-preserving", {
df2 <- data.frame(a = 1L, b = 5, g = 2L)
test_that("relational union_all(data.frame(a = 1L, b = 6, g = 2L)) %>% distinct(g) order-preserving", {
df2 <- data.frame(a = 1L, b = 6, g = 2L)
test_that("relational union_all(data.frame(a = 1L, b = 7, g = 2L)) %>% distinct(g) order-preserving", {
df2 <- data.frame(a = 1L, b = 7, g = 2L)
test_that("relational distinct(g, .keep_all = TRUE) order-preserving", {
test_that("relational distinct(a, b) order-enforcing", {
rel4 <- rel_order(rel3, list(expr_reference("a"), expr_reference("b")))
test_that("relational distinct(b, b) order-enforcing", {
test_that("relational union_all(data.frame(a = 1L, b = 3, g = 2L)) %>% distinct(g) order-enforcing", {
test_that("relational union_all(data.frame(a = 1L, b = 4, g = 2L)) %>% distinct(g) order-enforcing", {
test_that("relational union_all(data.frame(a = 1L, b = 5, g = 2L)) %>% distinct(g) order-enforcing", {
test_that("relational union_all(data.frame(a = 1L, b = 6, g = 2L)) %>% distinct(g) order-enforcing", {
test_that("relational union_all(data.frame(a = 1L, b = 7, g = 2L)) %>% distinct(g) order-enforcing", {
test_that("relational distinct(g, .keep_all = TRUE) order-enforcing", {
test_that("relational filter(a == 1) order-preserving", {
test_that("relational filter(a %in% 2:3, g == 2) order-preserving", {
invisible(dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y)'))
invisible(dbExecute(con, 'CREATE MACRO "|"(x, y) AS (x OR y)'))
test_that("relational filter(a %in% 2:3 & g == 2) order-preserving", {
invisible(dbExecute(con, 'CREATE MACRO "&"(x, y) AS (x AND y)'))
test_that("relational filter(a != 2 | g != 2) order-preserving", {
test_that("relational filter(a == 1) order-enforcing", {
test_that("relational filter(a %in% 2:3, g == 2) order-enforcing", {
test_that("relational filter(a %in% 2:3 & g == 2) order-enforcing", {
test_that("relational filter(a != 2 | g != 2) order-enforcing", {
expr_function("___eq_na_matches_na", list(expr_reference("a_x", rel7), expr_reference("a_y", rel8)))
tmp_expr <- expr_function("___coalesce", list(expr_reference("a_x", rel7), expr_reference("a_y", rel8)))
expr_function("___eq_na_matches_na", list(expr_reference("a_x", rel5), expr_reference("a_y", rel6)))
tmp_expr <- expr_function("___coalesce", list(expr_reference("a_x", rel5), expr_reference("a_y", rel6)))
expr_function("___eq_na_matches_na", list(expr_reference("a", rel5), expr_reference("a", rel4))),
expr_function("___eq_na_matches_na", list(expr_reference("b", rel5), expr_reference("b", rel4)))
test_that("relational mutate(a + 1) order-preserving", {
tmp_expr <- expr_function("+", list(expr_reference("a"), expr_constant(1)))
test_that("relational mutate(a + 1, .by = g) order-preserving", {
test_that("relational mutate(c = a + 1) order-preserving", {
test_that("relational mutate(`if` = a + 1) order-preserving", {
test_that("relational mutate(sum(a, na.rm = TRUE)) order-preserving", {
tmp_expr <- expr_window(expr_function("sum", list(expr_reference("a"))), list(), list(), offset_expr = NULL, default_expr = NULL)
expr_set_alias(tmp_expr, "sum(a, na.rm = TRUE)")
test_that("relational mutate(sum(a, na.rm = TRUE), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("sum", list(expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
tmp_expr <- expr_reference("sum(a, na.rm = TRUE)")
test_that("relational mutate(mean(a, na.rm = TRUE)) order-preserving", {
tmp_expr <- expr_window(expr_function("mean", list(x = expr_reference("a"))), list(), list(), offset_expr = NULL, default_expr = NULL)
expr_set_alias(tmp_expr, "mean(a, na.rm = TRUE)")
test_that("relational mutate(mean(a, na.rm = TRUE), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("mean", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
tmp_expr <- expr_reference("mean(a, na.rm = TRUE)")
test_that("relational mutate(sd(a, na.rm = TRUE)) order-preserving", {
tmp_expr <- expr_window(expr_function("stddev", list(x = expr_reference("a"))), list(), list(), offset_expr = NULL, default_expr = NULL)
expr_set_alias(tmp_expr, "sd(a, na.rm = TRUE)")
test_that("relational mutate(sd(a, na.rm = TRUE), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("stddev", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
tmp_expr <- expr_reference("sd(a, na.rm = TRUE)")
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(1L), default_expr = NULL)
test_that("relational mutate(lag(a), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(1L), default_expr = NULL)
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(1L), default_expr = NULL)
test_that("relational mutate(lead(a), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(1L), default_expr = NULL)
test_that("relational mutate(lag(a, 2)) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(2), default_expr = NULL)
test_that("relational mutate(lag(a, 2), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(2), default_expr = NULL)
test_that("relational mutate(lead(a, 2)) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(2), default_expr = NULL)
test_that("relational mutate(lead(a, 2), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(2), default_expr = NULL)
`lead(a, 2)` = c(NA, NA, NA, 6, NA, NA),
test_that("relational mutate(lag(a, 4)) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(4), default_expr = NULL)
test_that("relational mutate(lag(a, 4), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(4), default_expr = NULL)
test_that("relational mutate(lead(a, 4)) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(4), default_expr = NULL)
test_that("relational mutate(lead(a, 4), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(4), default_expr = NULL)
test_that("relational mutate(lag(a, default = 0)) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(1L), default_expr = expr_constant(0))
expr_set_alias(tmp_expr, "lag(a, default = 0)")
test_that("relational mutate(lag(a, default = 0), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lag", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(1L), default_expr = expr_constant(0))
tmp_expr <- expr_reference("lag(a, default = 0)")
test_that("relational mutate(lead(a, default = 1000)) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(), list(), offset_expr = expr_constant(1L), default_expr = expr_constant(1000))
expr_set_alias(tmp_expr, "lead(a, default = 1000)")
test_that("relational mutate(lead(a, default = 1000), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("lead", list(x = expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = expr_constant(1L), default_expr = expr_constant(1000))
tmp_expr <- expr_reference("lead(a, default = 1000)")
test_that("relational mutate(min(a, na.rm = TRUE)) order-preserving", {
tmp_expr <- expr_window(expr_function("min", list(expr_reference("a"))), list(), list(), offset_expr = NULL, default_expr = NULL)
expr_set_alias(tmp_expr, "min(a, na.rm = TRUE)")
test_that("relational mutate(min(a, na.rm = TRUE), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("min", list(expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
tmp_expr <- expr_reference("min(a, na.rm = TRUE)")
test_that("relational mutate(max(a, na.rm = TRUE)) order-preserving", {
tmp_expr <- expr_window(expr_function("max", list(expr_reference("a"))), list(), list(), offset_expr = NULL, default_expr = NULL)
expr_set_alias(tmp_expr, "max(a, na.rm = TRUE)")
test_that("relational mutate(max(a, na.rm = TRUE), .by = g) order-preserving", {
tmp_expr <- expr_window(expr_function("max", list(expr_reference("a"))), list(expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
tmp_expr <- expr_reference("max(a, na.rm = TRUE)")
test_that("relational mutate(a / b) order-preserving", {
r"[CREATE MACRO "___divide"(x, y) AS CASE WHEN y = 0 THEN CASE WHEN x = 0 THEN CAST('NaN' AS double) WHEN x > 0 THEN CAST('+Infinity' AS double) ELSE CAST('-Infinity' AS double) END ELSE CAST(x AS double) / y END]"
tmp_expr <- expr_function("___divide", list(expr_reference("a"), expr_reference("b")))
test_that("relational mutate(d = 0, e = 1 / d, f = 0 / d, g = -1 / d) order-preserving", {
tmp_expr <- expr_function("___divide", list(expr_constant(1), expr_reference("d")))
tmp_expr <- expr_function("___divide", list(expr_constant(0), expr_reference("d")))
data.frame(a = seq(1, 6, by = 1), b = 2, g = -Inf, d = 0, e = Inf, f = NaN)
test_that("relational mutate(c = 0, d = -1, e = log(c), f = suppressWarnings(log(d))) order-preserving", {
r"[CREATE MACRO "___log"(x) AS CASE WHEN x < 0 THEN CAST('NaN' AS double) WHEN x = 0 THEN CAST('-Inf' AS double) ELSE ln(x) END]"
invisible(dbExecute(con, 'CREATE MACRO "suppressWarnings"(x) AS (x)'))
tmp_expr <- expr_function("suppressWarnings", list(expr_function("___log", list(expr_reference("d")))))
test_that("relational mutate(c = 0, d = -1, e = log10(c), f = suppressWarnings(log10(d))) order-preserving", {
r"[CREATE MACRO "___log10"(x) AS CASE WHEN x < 0 THEN CAST('NaN' AS double) WHEN x = 0 THEN CAST('-Inf' AS double) ELSE log10(x) END]"
tmp_expr <- expr_function("suppressWarnings", list(expr_function("___log10", list(expr_reference("d")))))
test_that("relational mutate(c = 10, d = log(c)) order-preserving", {
test_that("relational mutate(c = 10, d = log10(c)) order-preserving", {
test_that("relational mutate(c = NA_character_, d = grepl('.', c)) order-preserving", {
'CREATE MACRO "grepl"(pattern, x) AS (CASE WHEN x IS NULL THEN FALSE ELSE regexp_matches(x, pattern) END)'
tmp_expr <- expr_function("grepl", list(expr_constant("."), expr_reference("c")))
test_that("relational mutate(c = 'abbc', d = gsub('(b|c)', 'z' , c)) order-preserving", {
r"[CREATE MACRO "gsub"(pattern, replacement, x) AS (regexp_replace(x, pattern, replacement, 'g'))]"
test_that("relational mutate(c = 'abbc', d = sub('(b|c)', 'z' , c)) order-preserving", {
'CREATE MACRO "sub"(pattern, replacement, x) AS (regexp_replace(x, pattern, replacement))'
test_that("relational mutate(c = NA_character_, d = gsub('.', '-' , c)) order-preserving", {
test_that("relational mutate(c = NA_character_, d = sub('.', '-' , c)) order-preserving", {
test_that("relational mutate(d = a %in% NA_real_) order-preserving", {
invisible(dbExecute(con, 'CREATE MACRO "is.na"(x) AS (x IS NULL)'))
test_that("relational mutate(d = a %in% NULL) order-preserving", {
test_that("relational mutate(d = a %in% integer()) order-preserving", {
test_that("relational mutate(d = NA_real_, e = is.na(d)) order-preserving", {
test_that("relational mutate(d = row_number()) order-preserving", {
expr_window(expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
test_that("relational mutate(d = row_number(), .by = g) order-preserving", {
expr_window(expr_function("row_number", list()), list(expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
test_that("relational mutate(c = .data$b) order-preserving", {
test_that("relational mutate(d = NA) order-preserving", {
invisible(dbExecute(con, 'CREATE MACRO "___null"() AS CAST(NULL AS BOOLEAN)'))
test_that("relational mutate(d = NA_integer_) order-preserving", {
data.frame(a = seq(1, 6, by = 1), b = 2, g = c(1L, 2L, 2L, 3L, 3L, 3L), d = NA_integer_)
test_that("relational mutate(d = NA_real_) order-preserving", {
test_that("relational mutate(d = NA_character_) order-preserving", {
data.frame(a = seq(1, 6, by = 1), b = 2, g = c(1L, 2L, 2L, 3L, 3L, 3L), d = NA_character_)
test_that("relational mutate(d = if_else(a > 1, \"ok\", NA)) order-preserving", {
'CREATE MACRO "if_else"(test, yes, no) AS (CASE WHEN test IS NULL THEN NULL ELSE CASE WHEN test THEN yes ELSE no END END)'
test_that("relational mutate(a + 1) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("a + 1"))
test_that("relational mutate(a + 1, .by = g) order-enforcing", {
test_that("relational mutate(c = a + 1) order-enforcing", {
test_that("relational mutate(`if` = a + 1) order-enforcing", {
test_that("relational mutate(sum(a, na.rm = TRUE)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("sum(a, na.rm = TRUE)"))
test_that("relational mutate(sum(a, na.rm = TRUE), .by = g) order-enforcing", {
test_that("relational mutate(mean(a, na.rm = TRUE)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("mean(a, na.rm = TRUE)"))
test_that("relational mutate(mean(a, na.rm = TRUE), .by = g) order-enforcing", {
test_that("relational mutate(sd(a, na.rm = TRUE)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("sd(a, na.rm = TRUE)"))
test_that("relational mutate(sd(a, na.rm = TRUE), .by = g) order-enforcing", {
test_that("relational mutate(lag(a), .by = g) order-enforcing", {
test_that("relational mutate(lead(a), .by = g) order-enforcing", {
test_that("relational mutate(lag(a, 2)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("lag(a, 2)"))
test_that("relational mutate(lag(a, 2), .by = g) order-enforcing", {
test_that("relational mutate(lead(a, 2)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("lead(a, 2)"))
test_that("relational mutate(lead(a, 2), .by = g) order-enforcing", {
test_that("relational mutate(lag(a, 4)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("lag(a, 4)"))
test_that("relational mutate(lag(a, 4), .by = g) order-enforcing", {
test_that("relational mutate(lead(a, 4)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("lead(a, 4)"))
test_that("relational mutate(lead(a, 4), .by = g) order-enforcing", {
test_that("relational mutate(lag(a, default = 0)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("lag(a, default = 0)"))
test_that("relational mutate(lag(a, default = 0), .by = g) order-enforcing", {
test_that("relational mutate(lead(a, default = 1000)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("lead(a, default = 1000)"))
test_that("relational mutate(lead(a, default = 1000), .by = g) order-enforcing", {
test_that("relational mutate(min(a, na.rm = TRUE)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("min(a, na.rm = TRUE)"))
test_that("relational mutate(min(a, na.rm = TRUE), .by = g) order-enforcing", {
test_that("relational mutate(max(a, na.rm = TRUE)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("max(a, na.rm = TRUE)"))
test_that("relational mutate(max(a, na.rm = TRUE), .by = g) order-enforcing", {
test_that("relational mutate(a / b) order-enforcing", {
test_that("relational mutate(d = 0, e = 1 / d, f = 0 / d, g = -1 / d) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("d"), expr_reference("e"), expr_reference("f"))
test_that("relational mutate(c = 0, d = -1, e = log(c), f = suppressWarnings(log(d))) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("c"), expr_reference("d"), expr_reference("e"), expr_reference("f"))
test_that("relational mutate(c = 0, d = -1, e = log10(c), f = suppressWarnings(log10(d))) order-enforcing", {
test_that("relational mutate(c = 10, d = log(c)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("c"), expr_reference("d"))
test_that("relational mutate(c = 10, d = log10(c)) order-enforcing", {
test_that("relational mutate(c = NA_character_, d = grepl('.', c)) order-enforcing", {
test_that("relational mutate(c = 'abbc', d = gsub('(b|c)', 'z' , c)) order-enforcing", {
test_that("relational mutate(c = 'abbc', d = sub('(b|c)', 'z' , c)) order-enforcing", {
test_that("relational mutate(c = NA_character_, d = gsub('.', '-' , c)) order-enforcing", {
test_that("relational mutate(c = NA_character_, d = sub('.', '-' , c)) order-enforcing", {
test_that("relational mutate(d = a %in% NA_real_) order-enforcing", {
test_that("relational mutate(d = a %in% NULL) order-enforcing", {
test_that("relational mutate(d = a %in% integer()) order-enforcing", {
test_that("relational mutate(d = NA_real_, e = is.na(d)) order-enforcing", {
list(expr_reference("a"), expr_reference("b"), expr_reference("g"), expr_reference("d"), expr_reference("e"))
test_that("relational mutate(d = row_number()) order-enforcing", {
test_that("relational mutate(d = row_number(), .by = g) order-enforcing", {
test_that("relational mutate(c = .data$b) order-enforcing", {
test_that("relational mutate(d = NA) order-enforcing", {
test_that("relational mutate(d = NA_integer_) order-enforcing", {
test_that("relational mutate(d = NA_real_) order-enforcing", {
test_that("relational mutate(d = NA_character_) order-enforcing", {
test_that("relational mutate(d = if_else(a > 1, \"ok\", NA)) order-enforcing", {
test_that("relational relocate(g, .before = b) order-preserving", {
test_that("relational relocate(a:b, .after = g) order-preserving", {
test_that("relational relocate(g, .before = b) order-enforcing", {
test_that("relational relocate(a:b, .after = g) order-enforcing", {
test_that("relational rename(c = a) order-preserving", {
test_that("relational rename(c = a) order-enforcing", {
rel3 <- rel_order(rel2, list(expr_reference("a"), expr_reference("b")))
test_that("relational slice_head(n = 2) order-preserving", {
test_that("relational slice_head(n = 2) order-enforcing", {
test_that("relational summarise(c = mean(a)) order-preserving", {
'CREATE MACRO "___mean_na"(x) AS (CASE WHEN SUM(CASE WHEN x IS NULL THEN 1 ELSE 0 END) > 0 THEN NULL ELSE AVG(x) END)'
tmp_expr <- expr_function("___mean_na", list(x = expr_reference("a")))
test_that("relational summarise(c = mean(a), .by = b) order-preserving", {
'CREATE MACRO "___min_na"(x) AS (CASE WHEN SUM(CASE WHEN x IS NULL THEN 1 ELSE 0 END) > 0 THEN NULL ELSE MIN(x) END)'
test_that("relational summarise(c = mean(a), .by = g) order-preserving", {
test_that("relational summarise(c = 1) order-preserving", {
test_that("relational summarise(c = 1, .by = g) order-preserving", {
test_that("relational summarise(n = n(), n = n() + 1L, .by = g) order-preserving", {
tmp_expr <- expr_function("+", list(expr_function("n", list()), expr_constant(1L)))
test_that("relational summarise(n = n(), n = n() + 1L) order-preserving", {
test_that("relational summarise(c = mean(a)) order-enforcing", {
test_that("relational summarise(c = mean(a), .by = b) order-enforcing", {
rel3 <- rel_order(rel2, list(expr_reference("b"), expr_reference("c")))
test_that("relational summarise(c = mean(a), .by = g) order-enforcing", {
rel3 <- rel_order(rel2, list(expr_reference("g"), expr_reference("c")))
test_that("relational summarise(c = 1) order-enforcing", {
test_that("relational summarise(c = 1, .by = g) order-enforcing", {
test_that("relational summarise(n = n(), n = n() + 1L, .by = g) order-enforcing", {
rel3 <- rel_order(rel2, list(expr_reference("g"), expr_reference("n")))
test_that("relational summarise(n = n(), n = n() + 1L) order-enforcing", {
test_that("relational transmute(c = a + 1) order-preserving", {
test_that("relational transmute(row = a) order-preserving", {
test_that("relational transmute(c = a + 1) order-enforcing", {
test_that("relational transmute(row = a) order-enforcing", {
rel5 <- rel_order(rel4, list(expr_reference("a"), expr_reference("b")))