Skip to content

Commit

Permalink
fixing missing encapsulated token scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
jortiz16 committed Aug 16, 2016
1 parent 52252c2 commit 44a1de1
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,30 +179,36 @@ public CSVFileScanFragment(
@Override
protected TupleBatch fetchNextReady() throws IOException, DbException {
long lineNumberBegin = lineNumber;
boolean unfinishedEncapsulatedTokenRow = false;

while ((buffer.numTuples() < TupleBatch.BATCH_SIZE) && !flagAsIncomplete) {
lineNumber++;
if (parser.isClosed()) {
break;
}

if (unfinishedEncapsulatedTokenRow) {
onLastRow = true;
}

try {
if (!onLastRow) {
record = iterator.next();
}
} catch (Exception e) {
/*
* FIX ME: If we hit an exception for a malformed row (in case of quotes for example), we read more bytes by
* marking this as the final line
*/
onLastRow = true;
}

try {
if (!iterator.hasNext()) {
onLastRow = true;
}
} catch (Exception e) {
/*
* FIX ME: Only mark if we hit an exception for a malformed row (in case of quotes for example)
*/
if (e.getMessage().contains("EOF reached before encapsulated token finished")) {
unfinishedEncapsulatedTokenRow = true;
}
}

if (record != null) {
Expand Down Expand Up @@ -261,6 +267,9 @@ record = iterator.next();
0);
iterator = parser.iterator();
record = iterator.next();
if (unfinishedEncapsulatedTokenRow) {
record = iterator.next();
}
finishedReadingLastRow = true;
} else {
byteOverlap *= 2;
Expand Down

0 comments on commit 44a1de1

Please sign in to comment.