Function Repository Resource:

# QueryTreeForm

Present a query as a tree

Contributed by: Seth J. Chandler
 ResourceFunction["QueryTreeForm"][q] presents a Query q as a tree in which the order of operations is the depth-first descent of the tree. ResourceFunction["QueryTreeForm"][{op1,op2,…,opn}] presents a list of operations for Query as a tree with depth-first descent.

## Details and Options

ResourceFunction["QueryTreeForm"] takes the same options as TreeForm.

## Examples

### Basic Examples (2)

Show the order of operations of a Query that is constructed of an ascending operator f and an ascending operator g as its arguments:

 In[1]:=
 Out[48]=

Show the order of operations of a Query that is constructed of: (1) a right composition of two descending operators and an ascending operator; (2) the All operator; and (3) the ascending operator i:

 In[49]:=
 Out[97]=

### Scope (3)

Visualize a Query composed of an ascending and a descending operator to aggregate values of a column after filtering the rows:

 In[98]:=
 Out[173]=

Visualize the order of operations of a Query that applies functions to each column independently:

 In[174]:=
 Out[250]=

Visualize a Query that constructs a new table by specifying operators that will compute each column:

 In[251]:=
 Out[331]=

### Options (1)

All the options of TreeForm are available to this function:

 In[332]:=
 Out[469]=

### Applications (1)

QueryTreeForm is useful in thinking through the order of operations in complex queries:

 In[470]:=
 Out[556]=

### Properties and Relations (1)

QueryTreeForm can be combined with other visualization functions to present additional information:

 In[557]:=
 Out[557]=

### Possible Issues (1)

Any ResourceFunction that does not format well within TreeForm does not format well in QueryTreeForm either:

 In[558]:=
 Out[668]=

### Neat Examples (2)

Determine the order of operations in a Query designed to produce several statistics of a dataset involving age, gender and class, broken down by gender:

 In[669]:=
 Out[784]=

A function that, if applied to the Titanic dataset, will yield a breakdown of survival by gender and class in an attractive format:

 In[785]:=
 In[786]:=
 Out[922]=

Seth J. Chandler

## Version History

• 1.0.0 – 15 July 2019