If the AGG was transformed to PROJECT + AGG, the hints of AGG should be propagated to the AGG node.
In current implementation, the hints would lost.
The perfect solution is to identify the replaced sub-tree, and for this tree, we should check which node is the right one to attach hints.
But for this patch, we only consider the new transformed node with pattern of PROJECT + "node of same kind of original", this solves most of the cases.
In current implementation, we try to match the first node of new relational expression sub-tree. The first node satisfies if it:
- Does not have any existing hints on it
- Can apply the original hints