Skip to content

Commit 84b5321

Browse files
committed
Corrected default null replacement value used
1 parent 9cb3a39 commit 84b5321

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/producer/CsvProducerTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ private String convertResultToCsv(Result result) {
118118
*/
119119
private String convertToString(Result result, String columnName, DataType dataType) {
120120
if (result.isNull(columnName)) {
121-
// "/N" is added when a column of text data type has null value. This is only converted for
121+
// "\N" is added when a column of text data type has null value. This is only converted for
122122
// CSV files
123123
if (dataType.equals(DataType.TEXT)) {
124-
return "/N";
124+
return "\\N";
125125
}
126126
return null;
127127
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/util/ColumnUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static Column<?> createColumnFromValue(
8484
throws ColumnParsingException {
8585
String columnName = columnInfo.getColumnName();
8686
if (value != null && (!dataType.equals(DataType.TEXT) && value.equalsIgnoreCase("null"))
87-
|| (dataType.equals(DataType.TEXT) && "/N".equals(value))) {
87+
|| (dataType.equals(DataType.TEXT) && "\\N".equals(value))) {
8888
value = null;
8989
}
9090
try {

data-loader/core/src/test/java/com/scalar/db/dataloader/core/dataexport/producer/CsvProducerTaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void process_withValidResultList_withPartialProjectionsAndMetadata_shouldReturnV
122122
void
123123
process_withValidResultListWithTextFieldWithNullValue_shouldReturnValidCsvStringWithCustomNullValueForTextField() {
124124
String expectedOutput =
125-
"9007199254740992,2147483647,true,0.000000000000000000000000000000000000000000001401298464324817,0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049,/N,YmxvYiB0ZXN0IHZhbHVl,2000-01-01,01:01:01,2000-01-01T01:01,1970-01-21T03:20:41.740Z,0.000000000000000000000000000000000000000000001401298464324817,0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049,test value,YmxvYiB0ZXN0IHZhbHVl,txt value 464654654,2147483647,2147483647,9007199254740992,9007199254740992,test value,2147483647,2147483647,9007199254740992,9007199254740992";
125+
"9007199254740992,2147483647,true,0.000000000000000000000000000000000000000000001401298464324817,0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049,\\N,YmxvYiB0ZXN0IHZhbHVl,2000-01-01,01:01:01,2000-01-01T01:01,1970-01-21T03:20:41.740Z,0.000000000000000000000000000000000000000000001401298464324817,0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049,test value,YmxvYiB0ZXN0IHZhbHVl,txt value 464654654,2147483647,2147483647,9007199254740992,9007199254740992,test value,2147483647,2147483647,9007199254740992,9007199254740992";
126126
Map<String, Column<?>> values = UnitTestUtils.createTestValues();
127127
String textColName = "col6";
128128
Column<?> col = values.get(textColName);

data-loader/core/src/test/java/com/scalar/db/dataloader/core/util/ColumnUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ void createColumnFromValue_valueIsNullString_shouldRemainLiteralForTextType()
315315
* treated as an actual null value
316316
*/
317317
@Test
318-
void createColumnFromValue_valueIsCustomNullValue_shouldRemainLiteralForTextType()
318+
void createColumnFromValue_customNullValueForText_shouldBeConvertedToNull()
319319
throws ColumnParsingException {
320320
String columnName = "textColumn";
321321
ColumnInfo columnInfo = ColumnInfo.builder().columnName(columnName).build();
322322

323-
Column<?> textCol = ColumnUtils.createColumnFromValue(DataType.TEXT, columnInfo, "/N");
323+
Column<?> textCol = ColumnUtils.createColumnFromValue(DataType.TEXT, columnInfo, "\\N");
324324
assertEquals(TextColumn.ofNull(columnName), textCol);
325325
}
326326
}

0 commit comments

Comments
 (0)