I am trying to parse an SQL statement, the output of which should provide me the formulas to create the columns using attributes from the table that is being ingested using the FROM clause.
Eg.
SELECT col1 AS a, SUM((col2/t2.col7 - col9)) AS b, col3 AS c FROM table1 join table2 as t2
WHERE col1 in (select col4 from t2)
The above statement when parsed should give output as:
Formula
SUM((col2/t2.col7 - col21))
The issue is the formula can contain subqueries which can have further SELECT statements.
Any help is appreciated.