Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/src/main/java/com/scalar/db/common/error/CoreError.java
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,12 @@ public enum CoreError implements ScalarDbError {
DATA_LOADER_FILE_PATH_IS_BLANK(
Category.USER_ERROR, "0197", "File path must not be blank.", "", ""),
DATA_LOADER_FILE_NOT_FOUND(Category.USER_ERROR, "0198", "File not found: %s", "", ""),
DATA_LOADER_INVALID_DATE_TIME_FOR_COLUMN_VALUE(
Category.USER_ERROR,
"0199",
"Invalid date time value specified for column %s in table %s in namespace %s.",
"",
""),

//
// Errors for the concurrency error category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashSet;
Expand Down Expand Up @@ -135,6 +136,11 @@ public static Column<?> createColumnFromValue(
CoreError.DATA_LOADER_INVALID_NUMBER_FORMAT_FOR_COLUMN_VALUE.buildMessage(
columnName, columnInfo.getTableName(), columnInfo.getNamespace()),
e);
} catch (DateTimeParseException e) {
throw new ColumnParsingException(
CoreError.DATA_LOADER_INVALID_DATE_TIME_FOR_COLUMN_VALUE.buildMessage(
columnName, columnInfo.getTableName(), columnInfo.getNamespace()),
e);
} catch (IllegalArgumentException e) {
throw new ColumnParsingException(
CoreError.DATA_LOADER_INVALID_BASE64_ENCODING_FOR_COLUMN_VALUE.buildMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ void createColumnFromValue_invalidBase64_throwsBase64Exception() {
columnName, "table", "ns"),
exception.getMessage());
}
/**
* Tests that attempting to create a date time column with an invalid format throws a
* DateTimeParseException with appropriate error message.
*/
@Test
void createColumnFromValue_invalidDateTimeFormat_throwsDateTimeParseException() {
String columnName = "timestampColumn";
String value = "not_a_timestamp";
ColumnInfo columnInfo =
ColumnInfo.builder().namespace("ns").tableName("table").columnName(columnName).build();
ColumnParsingException exception =
assertThrows(
ColumnParsingException.class,
() -> ColumnUtils.createColumnFromValue(DataType.TIMESTAMP, columnInfo, value));
assertEquals(
CoreError.DATA_LOADER_INVALID_DATE_TIME_FOR_COLUMN_VALUE.buildMessage(
columnName, "table", "ns"),
exception.getMessage());
}

/**
* Tests the extraction of columns from a ScalarDB Result object. Verifies that all columns are
Expand Down