Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3417#discussion_r103203173
  
    --- Diff: 
flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java
 ---
    @@ -358,24 +358,27 @@ protected boolean parseRecord(Object[] holders, 
byte[] bytes, int offset, int nu
                for (int field = 0, output = 0; field < fieldIncluded.length; 
field++) {
                        
                        // check valid start position
    -                   if (startPos >= limit) {
    +                   if (startPos > limit || (startPos == limit && field != 
fieldIncluded.length - 1)) {
                                if (lenient) {
                                        return false;
                                } else {
                                        throw new ParseException("Row too 
short: " + new String(bytes, offset, numBytes));
                                }
                        }
    -                   
    +
                        if (fieldIncluded[field]) {
                                // parse field
                                @SuppressWarnings("unchecked")
                                FieldParser<Object> parser = 
(FieldParser<Object>) this.fieldParsers[output];
                                Object reuse = holders[output];
                                startPos = 
parser.resetErrorStateAndParse(bytes, startPos, limit, this.fieldDelim, reuse);
                                holders[output] = parser.getLastResult();
    -                           
    +
                                // check parse result
    -                           if (startPos < 0) {
    +                           if (startPos < 0 ||
    +                                           (startPos == limit
    --- End diff --
    
    Move this condition into an `else if` branch and give a more detailed error 
message (row to short).
    Also add a comment that we read the whole records but that there are fields 
missing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to