From fafbd5b4e9bf305b2fde8b083020d42eee182df2 Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 26 Dec 2025 12:47:48 +0900 Subject: [PATCH] Add tests for filter() and arrange() with aggregation expressions --- r/R/dplyr-arrange.R | 3 +-- r/R/dplyr-filter.R | 1 - r/tests/testthat/test-dplyr-arrange.R | 8 ++++++++ r/tests/testthat/test-dplyr-filter.R | 8 ++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/r/R/dplyr-arrange.R b/r/R/dplyr-arrange.R index 977ccf98607..5394eeb5397 100644 --- a/r/R/dplyr-arrange.R +++ b/r/R/dplyr-arrange.R @@ -46,10 +46,9 @@ arrange.arrow_dplyr_query <- function(.data, ..., .by_group = FALSE) { # dplyr lets you arrange on e.g. x < mean(x), but we haven't implemented it. # But we could, the same way it works in mutate() via join, if someone asks. # Until then, just error. - # TODO: add a test for this arrow_not_supported( .actual_msg = "Expression not supported in arrange() in Arrow", - call = expr + call = exprs[[i]] ) } descs[i] <- x[["desc"]] diff --git a/r/R/dplyr-filter.R b/r/R/dplyr-filter.R index 6f64749bbcd..18f5c929aff 100644 --- a/r/R/dplyr-filter.R +++ b/r/R/dplyr-filter.R @@ -42,7 +42,6 @@ filter.arrow_dplyr_query <- function(.data, ..., .by = NULL, .preserve = FALSE) # dplyr lets you filter on e.g. x < mean(x), but we haven't implemented it. # But we could, the same way it works in mutate() via join, if someone asks. # Until then, just error. - # TODO: add a test for this arrow_not_supported( .actual_msg = "Expression not supported in filter() in Arrow", call = expr diff --git a/r/tests/testthat/test-dplyr-arrange.R b/r/tests/testthat/test-dplyr-arrange.R index c0e2b859c1c..d502a7f040a 100644 --- a/r/tests/testthat/test-dplyr-arrange.R +++ b/r/tests/testthat/test-dplyr-arrange.R @@ -245,3 +245,11 @@ test_that("Can use across() within arrange()", { example_data ) }) + +test_that("arrange() with aggregation expressions errors", { + tab <- arrow_table(tbl) + expect_warning( + tab |> arrange(int < mean(int)), + "not supported in arrange" + ) +}) diff --git a/r/tests/testthat/test-dplyr-filter.R b/r/tests/testthat/test-dplyr-filter.R index 23d49feb3b3..d56e25fca32 100644 --- a/r/tests/testthat/test-dplyr-filter.R +++ b/r/tests/testthat/test-dplyr-filter.R @@ -490,3 +490,11 @@ test_that(".by argument", { "Can't supply `\\.by` when `\\.data` is grouped data" ) }) + +test_that("filter() with aggregation expressions errors", { + tab <- arrow_table(tbl) + expect_warning( + tab |> filter(int < mean(int)), + "not supported in filter" + ) +})