"What about "select A + B from R1 group by A + B, C order by C?"
This query is a complex aggregation query that need a projection node, its code pass is different. The comment is based on there is no complex aggregation and there is a complex group by.

"select A + B from R1 group by A + B order by ABS(A + B)" currently will break the code here. I assume that we should do recursively TVEs replacing or we let A and B be pass through columns. Thanks.