TEIID-2327 using the condition with masking, adding a type check, and
switching order to be descending