lukecwik commented on a change in pull request #15566:
URL: https://github.com/apache/beam/pull/15566#discussion_r718024398



##########
File path: 
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/SchemaUtil.java
##########
@@ -351,7 +351,12 @@ private BeamRowMapper(Schema schema, 
List<ResultSetFieldExtractor> fieldExtracto
     public Row mapRow(ResultSet rs) throws Exception {
       Row.Builder rowBuilder = Row.withSchema(schema);
       for (int i = 0; i < schema.getFieldCount(); i++) {
-        rowBuilder.addValue(fieldExtractors.get(i).extract(rs, i + 1));
+        Object value = fieldExtractors.get(i).extract(rs, i + 1);
+        if (rs.wasNull() && schema.getField(i).getType().getNullable()) {
+          rowBuilder.addValue(null);
+        } else {
+          rowBuilder.addValue(value);

Review comment:
       Incorrect data is worse. Users can fix issues with schemas if there is 
an error but silent data mismatch typically goes unnoticed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to