queryparser icon indicating copy to clipboard operation
queryparser copied to clipboard

Add support for UNION

Open StevenHibble opened this issue 4 years ago • 3 comments

UNION [ALL] is probably the most popular set operation in SQL. It may be the easiest to implement as well.

This might affect the structure of parse_query's output. That will probably have effects on tidyquery.

Initial thoughts on options:

  1. Keep everything flat
  2. Add another level to the structure

parse_query("select x from df1 union select x from df2")

Option 1:

$`select` $`select`[[1]] x

$from $from[[1]] df1

$set_op [1] union

$`select` $`select`[[1]] x

$from $from[[1]] df2

Option 2:

[[1]] [[1]]$`select` [[1]]$`select`[[1]] x

[[1]]$from [[1]]$from[[1]] df1

$set_op [1] union

[[3]] [[3]]$`select` [[3]]$`select`[[1]] x

[[3]]$from [[3]]$from[[1]] df2

StevenHibble avatar Feb 05 '20 18:02 StevenHibble