Julian Hyde, It turned out that adding that single line of change exposed a few other issues in SubstitutionVisitor:
1. Because the Project over "select *" statement no longer exists, what used to match "ProjectToProjectUnifyRule1" now goes to "FilterToFilterUnifyRule" or "FilterToProjectUnifyRule".
2. The FilterToFilterUnifyRule has not been covered by any test cases before and does not work correctly at all after (1).
3. Small bug in "FilterToProjectUnifyRule": it should have checked that the new projects have full coverage for the node it's going to replace.
4. In SubstitutionVisitor.go(), we should not remove all corresponding entries once we find a match, since there can be multiple identical rels in the query, e.g. a self-join has two identical TableScans.
Could you please take a look at https://github.com/maryannxue/calcite/tree/calcite-1182? It works for all the test case including a newly added one, but I would like to suggest more code refinement to reduce code redundancy.