Skip to content

Commit

Permalink
Permit only known functions
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Aug 7, 2023
1 parent cff7d09 commit 4c6fb6b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions R/relational.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ rel_translate <- function(
NULL
)

if (name %in% names(aliases)) {
name <- aliases[[name]]
}
# name <- aliases[name] %|% name

window <- need_window && (name %in% c(
known_window <- c(
# Window functions
"rank", "rank_dense", "dense_rank", "percent_rank",
"row_number", "first_value", "last_value", "nth_value",
Expand All @@ -137,7 +132,22 @@ rel_translate <- function(
"sum", "mean", "stddev", "min", "max",

NULL
))
)

known_ops <- c("+", "-", "*", "/")

known <- c(names(duckplyr_macros), names(aliases), known_window, known_ops)

if (!(name %in% known)) {
abort(paste0("Unknown function: ", name))
}

if (name %in% names(aliases)) {
name <- aliases[[name]]
}
# name <- aliases[name] %|% name

window <- need_window && (name %in% known_window)

order_bys <- list()
offset_expr <- NULL
Expand Down

0 comments on commit 4c6fb6b

Please sign in to comment.