Fixed an bug introduced by the last commit on nullable field when
loading csv file; addressed Till's comments.
diff --git a/asterix-app/data/csv/sample_01.csv b/asterix-app/data/csv/sample_01.csv
index 285a30d..a77258c 100644
--- a/asterix-app/data/csv/sample_01.csv
+++ b/asterix-app/data/csv/sample_01.csv
@@ -1,4 +1,4 @@
1,0.899682764,5.6256,2013-08-07,07:22:35,1979-02-25T23:48:27.034
-2,0.669052398,0.446192,-1923-03-29,19:33:34,-1979-02-25T23:48:27.002
+2,0.669052398,,-1923-03-29,19:33:34,-1979-02-25T23:48:27.002
,,,,,,,,,,
3,0.572733058,192674,-1923-03-29,19:33:34,-1979-02-25T23:48:27.001
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/csv_01/csv_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/load/csv_01/csv_01.1.ddl.aql
index 4a9b7af..7a0e4b0 100644
--- a/asterix-app/src/test/resources/runtimets/queries/load/csv_01/csv_01.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/load/csv_01/csv_01.1.ddl.aql
@@ -10,9 +10,9 @@
use dataverse temp;
create type test as closed {
- id: int32,
- float: float,
- double: double,
+ id: string,
+ float: string,
+ double: string,
date: string,
time: string,
datetime: string
diff --git a/asterix-app/src/test/resources/runtimets/results/load/csv_01/csv_01.1.adm b/asterix-app/src/test/resources/runtimets/results/load/csv_01/csv_01.1.adm
index 8287a4a..1e28c78 100644
--- a/asterix-app/src/test/resources/runtimets/results/load/csv_01/csv_01.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/load/csv_01/csv_01.1.adm
@@ -1,3 +1,3 @@
-{ "id": 1, "float": 0.89968276f, "double": 5.6256d, "date": date("2013-08-07"), "time": time("07:22:35.000Z"), "datetime": datetime("1979-02-25T23:48:27.034Z") }
-{ "id": 2, "float": 0.6690524f, "double": 0.446192d, "date": date("-1923-03-29"), "time": time("19:33:34.000Z"), "datetime": datetime("-1979-02-25T23:48:27.002Z") }
-{ "id": 3, "float": 0.57273304f, "double": 192674.0d, "date": date("-1923-03-29"), "time": time("19:33:34.000Z"), "datetime": datetime("-1979-02-25T23:48:27.001Z") }
\ No newline at end of file
+{ "id": "1", "float": "0.899682764", "double": "5.6256", "date": date("2013-08-07"), "time": time("07:22:35.000Z"), "datetime": datetime("1979-02-25T23:48:27.034Z") }
+{ "id": "3", "float": "0.572733058", "double": "192674", "date": date("-1923-03-29"), "time": time("19:33:34.000Z"), "datetime": datetime("-1979-02-25T23:48:27.001Z") }
+{ "id": "2", "float": "0.669052398", "double": "", "date": date("-1923-03-29"), "time": time("19:33:34.000Z"), "datetime": datetime("-1979-02-25T23:48:27.002Z") }
\ No newline at end of file
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataParser.java
index 0e8724e..85242ec 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/DelimitedDataParser.java
@@ -109,14 +109,12 @@
}
fieldValueBuffer.reset();
- if (cursor.fStart == cursor.fEnd) {
- fieldValueBufferOutput.writeByte(ATypeTag.NULL.serialize());
- } else {
- fieldValueBufferOutput.writeByte(fieldTypeTags[i]);
- valueParsers[i].parse(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart,
- fieldValueBufferOutput);
+ if (cursor.fStart != cursor.fEnd) {
areAllNullFields = false;
}
+ fieldValueBufferOutput.writeByte(fieldTypeTags[i]);
+ valueParsers[i]
+ .parse(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart, fieldValueBufferOutput);
if (fldIds[i] < 0) {
recBuilder.addField(nameBuffers[i], fieldValueBuffer);
} else {
@@ -261,13 +259,13 @@
if (p >= end) {
int s = start;
eof = !readMore();
+ p -= (s - start);
if (eof) {
state = State.EOF;
fStart = start;
- fEnd = p - (s - start);
+ fEnd = p;
return true;
}
- p -= (s - start);
}
char ch = buffer[p];
if (ch == fieldDelimiter) {