I'm using a table where I have to do this operation where I group_by, and mutate by n_distinct, and this is necessary for me to carry out my next step, I'm just showing casing mtcars here because I want to learn how to do this on my dataset
tbl_mtcars <- copy_to(sc, mtcars, "spark_mtcars")
tbl_mtcars%>%
group_by(gear)%>%
mutate(n=n_distinct(cyl))
Window function DISTINCT() is not supported by this database