lacquer
lacquer copied to clipboard
SQL Parser derived from Presto, written in Python with the PLY framework
Based on examples/gather_columns.py and other needs, it'd be good to see if we can define a API for answering common questions about queries, like what tables and columns are referenced...
It'd be great to be able to successfully say we can parse all TPC-H queries without error. A list of the ones presto uses (with some additional presto-specific stuff): https://github.com/prestodb/presto/tree/master/presto-parser/src/test/resources/tpch/queries
I don't think this will be too hard, but I think my initial implementation of these generated a few shift/reduce conflicts.
This PR augments the `print_column_resolution_order` method to also examine columns which are function calls, so queries of the form ```sql SELECT SUM(foo) FROM a ``` associate the column `foo` with...
The Redbaron project has an Syntax Tree query interface: https://redbaron.readthedocs.io/en/latest/querying.html Which is partially implemented as such: https://github.com/PyCQA/redbaron/blob/master/redbaron/base_nodes.py#L804 Conceivably, we should be able to use the Visitor pattern to implement this....