[ 
https://issues.apache.org/jira/browse/BEAM-12925?focusedWorklogId=656943&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-656943
 ]

ASF GitHub Bot logged work on BEAM-12925:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Sep/21 22:59
            Start Date: 28/Sep/21 22:59
    Worklog Time Spent: 10m 
      Work Description: 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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 656943)
    Time Spent: 1h 10m  (was: 1h)

> JdbcIo readRows does not handle null numerical values properly
> --------------------------------------------------------------
>
>                 Key: BEAM-12925
>                 URL: https://issues.apache.org/jira/browse/BEAM-12925
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-jdbc
>    Affects Versions: 2.32.0
>            Reporter: Chris Gray
>            Priority: P2
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Numerical values that are SQL NULL in the database are converted to 0 when 
> read by `readRows`.  This appears to be caused by SchemaUtil.java not 
> checking `ResultSet::wasNull` at line 253 in version 2.32.0.  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to