Skip to content

Odd return value in snowflake query #1607

@PHilden-RP

Description

@PHilden-RP

Running the below query on a snowflake database returns the NULL values of grp, where I would expect it would return the max val for which grp is not NULL

tmp <-
  tibble(
    grp = c(NA, "grp1", "grp2", "grp2"),
    val = c(4, 3, 2, 1)
  ) %>% 
  mutate(id = "abc") %>% 
  relocate(id)

tmp_con <- copy_to(con, tmp, I("DATABASE.SCHEMA.TMP"), overwrite = TRUE)

tmp_con %>% 
  group_by(id) %>%
  slice_max(val[!is.na(grp)], with_ties = FALSE) %>% 
  ungroup()

Currently results from the above query

Image

I would have expected this to return the 2nd row in tmp, which is the one with the largest val in which grp is not NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions