parse_expression: Parse a SQL expression

View source: R/parse_expression.R

parse_expressionR Documentation

Parse a SQL expression

Description

Parses a SQL expression into an R expression

Usage

parse_expression(expr, tidyverse = FALSE, secure = TRUE)

Arguments

expr

a character string containing a SQL expression

tidyverse

set to TRUE to use functions from tidyverse packages including dplyr, stringr, and lubridate in the returned R expression

secure

set to FALSE to allow potentially dangerous functions in the returned R expression

Details

The expression must not end with a column alias assignment. Use extract_alias to extract and remove column alias assignments.

The expression must not contain any unquoted whitespace characters except spaces, and there must be no unquoted runs or two or more spaces. The expression must not contain line comments (--) or block comments (/* */). Use squish_sql to satisfy these whitespace requirements and remove any comments.

Value

an unevaluated R expression (a call)

See Also

parse_query

Examples

expr <- "round(AVG(arr_delay))"
parse_expression(expr)

queryparser documentation built on Jan. 10, 2023, 1:08 a.m.