generating IS NOT NULL condition only when necessary