TEIID-3011 adding a better check as to when to skip rewrite