Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement n() in Arrow bindings #227

Closed
wants to merge 3 commits into from

Conversation

thisisnic
Copy link
Contributor

@thisisnic thisisnic commented Dec 5, 2022

Fixes #219. However, this is not mergable yet due to what I think is a bug in the Arrow consumer. I have opened ARROW-18403 to report this.

library(arrow)
library(substrait)
library(dplyr)

data = tibble::tibble(
  x = 1:10,
  grp = c(rep(c("a", "b"), each = 4), NA, NA)
)

data
#> # A tibble: 10 × 2
#>        x grp  
#>    <int> <chr>
#>  1     1 a    
#>  2     2 a    
#>  3     3 a    
#>  4     4 a    
#>  5     5 b    
#>  6     6 b    
#>  7     7 b    
#>  8     8 b    
#>  9     9 <NA> 
#> 10    10 <NA>

data %>%
  arrow_substrait_compiler() %>%
  group_by(grp) %>%
  summarise(total_group_members = n(x)) %>%
  collect()
#> # A tibble: 3 × 2
#>     grp total_group_members
#>   <int> <chr>              
#> 1     4 a                  
#> 2     4 b                  
#> 3     2 <NA>

data %>%
  arrow_substrait_compiler() %>%
  group_by(grp) %>%
  summarise(total_group_members = n(grp)) %>%
  collect()
#> # A tibble: 3 × 2
#>     grp total_group_members
#>   <int> <chr>              
#> 1     4 a                  
#> 2     4 b                  
#> 3     0 <NA>

data %>%
  arrow_substrait_compiler() %>%
  summarise(total_group_members = n(x)) %>%
  collect()
#> # A tibble: 1 × 1
#>   total_group_members
#>                 <int>
#> 1                  10

data %>%
  arrow_substrait_compiler() %>%
  summarise(total_group_members = n(grp)) %>%
  collect()
#> # A tibble: 1 × 1
#>   total_group_members
#>                 <int>
#> 1                   8

@thisisnic thisisnic closed this Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement n() function (Arrow)
1 participant