chrismgrayftsinc commented on a change in pull request #15566:
URL: https://github.com/apache/beam/pull/15566#discussion_r717838656
##########
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:
Just to expand on backwards-compatibility a bit, if we added the null
value to rows where the schema did not have the field as being nullable, then
an exception would be thrown where it wasn't thrown before from
`RowFieldMatcher.match`. So the question is whether incorrect data is worse or
newly-introduced crashes are worse.
--
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]