TEIID-2804 reducing the scope of the empty check and correcting to only
use count(*)