column_references: Return the column references in a parsed SQL query

View source: R/column_references.R

column_referencesR Documentation

Return the column references in a parsed SQL query

Description

Returns a character vector containing all the column references in the clauses of a parsed SQL SELECT statement

Usage

column_references(tree, from = TRUE)

Arguments

tree

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

from

a logical value indicating whether to include the column references from the join conditions in the FROM clause

Details

The returned character vector includes only column references, not table references. Column aliases assigned in the SELECT list are not included unless they are used in other clauses.

Value

A character vector containing all the unique column references found in the SELECT, FROM (if from = TRUE), WHERE, GROUP BY, HAVING, and ORDER BY clauses of the SELECT statement

See Also

parse_query

Examples

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

column_references(parse_query(my_query), from = FALSE)

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