query-operator {queryBuilder}R Documentation

Register new or list existing query operators

Description

Operator are functions of maximum two arguments. The first argument is interpreted as a field (e.g. column name), the second one as a filtering value interpreted by operator accordingly. Some operators, such as 'is_empty' (that compares field values to empty string) don't require any value provided.

Usage

queryOperator(method)

setQueryOperators(..., .queryBuilderConfig = queryBuilderConfig)

listQueryOperators(.queryBuilderConfig = queryBuilderConfig, print = TRUE)

default_operators

Arguments

method

R function the operator should be transformed to when parsing result to R expression. The function should take at most two parameters. The first one (obligatory) is variable vector, the second one additional parameters interpreted by operator. Could be negated with exclamation mark e.g. queryOperator(!startsWith) which will be interpreted as the negation of the associated expression.

...

Name-value pairs defining operator name and method respectively. Should be defined with usage of queryOperator function.

.queryBuilderConfig

R6 class object storing query configuration. See queryBuilderConfigClass.

print

Should the list of operators be printed into console?

Format

An object of class list of length 20.

Details

Operators are stored as quotes, that are further interpreted while converting the query to filtering expression.

Value

A single 'quote' storing the provided method.

Examples


listQueryOperators()

in_closed_range <- function(x, range) {
  x >= range[1] & x <= range[2]
}

setQueryOperators(
  "within" = queryOperator(in_closed_range),
  "not_within" = queryOperator(!in_closed_range)
)
query <- queryGroup(
  condition = "AND",
  queryRule("am", "equal", 1),
  queryRule("qsec", "within", c(10, 15)),
  queryRule("disp", "not_within", c(10, 15))
)
queryToExpr(query)


[Package queryBuilder version 0.1.0 Index]