aipescience / queryparser

Parsing, processing, and translation of PostgreSQL, MySQL and ADQL queries
Apache License 2.0
13 stars 4 forks source link

Inspect `Where` clause #17

Open burnout87 opened 1 month ago

burnout87 commented 1 month ago

What is the recommended way to extract the Where clause from a PostgreSQLQueryProcessor object after the process_query function has been called?

To be more precise, I'd like to know the conditions in the clause (eg the comparisons), knowing the columns involved, the values against which the comparisons are made etc

Thanks

kimakan commented 1 month ago

The SQLQueryProcessor does not provide any information about the WHERE clause. It "only" checks the syntax and creates lists of columns, tables etc. We've never required this functionality in our services since the processed queries are executed directly in the database. Although the query processor provides the walker, listener and parser that might be used for some kind of post-processing of the query, personally, I wouldn't know how to do it right away. Maybe @mtjvc can give a hint?