Skip to content

Commit

Permalink
Fixed Serialization/Deserialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
Megan Foss committed Oct 21, 2021
1 parent c900037 commit a91be4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ private boolean parseLine(String line, RowSetLoader writer) throws IOException {
for (FixedwidthFieldConfig field : config.getFields()) {
value = line.substring(field.getIndex() - 1, field.getIndex() + field.getWidth() - 1);
dataType = field.getType();
dateTimeFormat = field.getDateTimeFormat();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateTimeFormat, Locale.ENGLISH);
try {
switch (dataType) {
case INT:
Expand All @@ -154,15 +152,21 @@ private boolean parseLine(String line, RowSetLoader writer) throws IOException {
writer.scalar(i).setString(value);
break;
case DATE:
dateTimeFormat = field.getDateTimeFormat();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateTimeFormat, Locale.ENGLISH);
LocalDate date = LocalDate.parse(value, formatter);
writer.scalar(i).setDate(date);
break;
case TIME:
LocalTime time = LocalTime.parse(value, formatter);
dateTimeFormat = field.getDateTimeFormat();
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern(dateTimeFormat, Locale.ENGLISH);
LocalTime time = LocalTime.parse(value, formatter2);
writer.scalar(i).setTime(time);
break;
case TIMESTAMP:
LocalDateTime ldt = LocalDateTime.parse(value, formatter);
dateTimeFormat = field.getDateTimeFormat();
DateTimeFormatter formatter3 = DateTimeFormatter.ofPattern(dateTimeFormat, Locale.ENGLISH);
LocalDateTime ldt = LocalDateTime.parse(value, formatter3);
ZoneId z = ZoneId.of("America/Toronto");
ZonedDateTime zdt = ldt.atZone(z);
Instant timeStamp = zdt.toInstant();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public void testExplicitQuery() throws Exception {
//Test Serialization/Deserialization
@Test
public void testSerDe() throws Exception {
String sql = "SELECT COUNT(*) FROM dfs.`fwf/test.fwf`";
String sql = "SELECT COUNT(*) FROM cp.`fwf/test.fwf`";
String plan = queryBuilder().sql(sql).explainJson();
long cnt = queryBuilder().physical(plan).singletonLong();
assertEquals(5L, cnt);
assertEquals(25L, cnt);
}

@Test
Expand Down

0 comments on commit a91be4c

Please sign in to comment.