We use "checkInputForCollationAndLimit" in RelMdUtil.java to check the input #rows. However, it calls RelMetadataQuery.getRowCount which will validate the #rows. The validation will change #row=0 to #row=1. This will result in an infinite loop to push limit. The affected rules include
SortUnionTransposeRule and any Sort***TransposeRules that call checkInputForCollationAndLimit.