Learn R Programming

queryparser (version 0.3.2)

unqualify_query: Remove prefixes from column references in a parsed SQL query

Description

Unqualifies column references in the clauses of a parsed SQL SELECT statement that begin with any of the specified prefixes followed by a dot

Usage

unqualify_query(tree, prefixes, except = character(0))

Value

A list the same as tree but with all column references in the

SELECT, WHERE, GROUP BY, HAVING, and

ORDER BY clauses unqualified, except those in except

Arguments

tree

a list returned by parse_query containing named elements representing the clauses of a SQL SELECT statement

prefixes

a character vector containing one or more table names or table aliases

except

a character vector containing column references to leave as is (optional)

Details

In the returned list, the FROM clause is unmodified and column alias assignments made in the SELECT clause are unmodified.

See Also

parse_query

Examples

Run this code
my_query <- "SELECT f.flight,
    manufacturer, p.model
  FROM flights f
    JOIN planes p USING (tailnum);"

unqualify_query(
  parse_query(my_query),
  prefixes = c("p", "f")
)

Run the code above in your browser using DataLab