One option for cases where we have an SQL AST is to do this earlier when we have the SQL AST and use a SqlAstWalker.