Skip to content

Commit 3aa9ab6

Browse files
committed
Revert "ORC-546. Fix reading timestamps with duplicated millis within a second."
This reverts commit f936740. Signed-off-by: Owen O'Malley <[email protected]>
1 parent 9891eae commit 3aa9ab6

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,9 +1017,9 @@ public void nextVector(ColumnVector previousVector,
10171017

10181018
for (int i = 0; i < batchSize; i++) {
10191019
if (result.noNulls || !result.isNull[i]) {
1020-
int newNanos = parseNanos(nanos.next());
1020+
final int newNanos = parseNanos(nanos.next());
10211021
long millis = (data.next() + base_timestamp)
1022-
* TimestampTreeWriter.MILLIS_PER_SECOND;
1022+
* TimestampTreeWriter.MILLIS_PER_SECOND + newNanos / 1_000_000;
10231023
if (millis < 0 && newNanos > 999_999) {
10241024
millis -= TimestampTreeWriter.MILLIS_PER_SECOND;
10251025
}

java/core/src/test/org/apache/orc/TestVectorOrcFile.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
import java.security.NoSuchAlgorithmException;
8181
import java.sql.Date;
8282
import java.sql.Timestamp;
83-
import java.time.format.DateTimeFormatter;
8483
import java.util.ArrayList;
8584
import java.util.Arrays;
8685
import java.util.Collection;
@@ -1449,17 +1448,16 @@ public void createOrcDateFile(Path file, int minYear, int maxYear
14491448
batch = reader.getSchema().createRowBatch(1000);
14501449
TimestampColumnVector times = (TimestampColumnVector) batch.cols[0];
14511450
LongColumnVector dates = (LongColumnVector) batch.cols[1];
1452-
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSS");
14531451
for (int year = minYear; year < maxYear; ++year) {
14541452
rows.nextBatch(batch);
14551453
assertEquals(1000, batch.size);
14561454
for(int row = 0; row < 1000; ++row) {
1457-
String expectedStr = String.format("%04d-05-05 12:34:56.%04d", year, 2*row);
1458-
assertEquals("row " + row, expectedStr,
1459-
formatter.format(times.asScratchTimestamp(row).toLocalDateTime()));
1460-
assertEquals(0, times.time[row] % 1000);
1461-
assertTrue("nano " + row + " = " + times.nanos[row],
1462-
times.nanos[row] >= 0 && times.nanos[row] < 1_000_000_000);
1455+
Timestamp expected = Timestamp.valueOf(
1456+
String.format("%04d-05-05 12:34:56.%04d", year, 2*row));
1457+
assertEquals("ms row " + row + " " + expected, expected.getTime(),
1458+
times.time[row]);
1459+
assertEquals("nanos row " + row + " " + expected, expected.getNanos(),
1460+
times.nanos[row]);
14631461
assertEquals("year " + year + " row " + row,
14641462
Integer.toString(year) + "-12-25",
14651463
new DateWritable((int) dates.vector[row]).toString());

0 commit comments

Comments
 (0)