Refactor the query engine of h2, ast -> logical plan