[MONDRIAN-1729][SP-632] "Query required more than 12 iterations" error

Pull req for 3.6.