Example tables:
relation: people, number_of_friends
people’s columns: name(varchar), age(int), faction(varchar)
number_of_friends columns: name(varchar), friends(int)
Example query:
SELECT * FROM peoplearg(1,5) → 1 output 5 arg
batcalc.c
The sql query string were processed by the lexer to keywords and then rules defined inside the sql_parser.yfile which is a bison syntax, then converted to the symbol tree below:

Then, the symbol tree was converted to a sql_rel tree
First deal with table reference:
Call chain: sql_symbol2relation → rel_semantic → rel_selects → rel_subquery → rel_query → table_ref → rel_basetable
`rel_query`→ `rel_select_exp` → `rel_table_exp` → `rel_table_projections` → `_rel_projection` → `rel_base_projection` (Get column expressions from the sql_table struct’s column linked list)
rel_select_exp → rel_project

Call chain:
composed first stmt node(tid & bind) sql_relation2stmt → output_rel_bin→ subrel_bin → rel2bin_project → subrel_bin → rel2bin_basetable