workflow of query compilation