Add data existence check in code generation.