Skip to content

Commit

Permalink
Add Java tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nghia Truong <[email protected]>
  • Loading branch information
ttnghia committed Nov 1, 2023
1 parent ce06a46 commit 112b261
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions src/test/java/com/nvidia/spark/rapids/jni/DateTimeRebaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

public class DateTimeRebaseTest {
@Test
void dayTimestampTest() {
void rebaseDaysToJulianTest() {
try (ColumnVector input = ColumnVector.timestampDaysFromBoxedInts(-719162, -354285, null,
-141714, -141438, -141437,
null, null,
Expand All @@ -39,12 +39,28 @@ void dayTimestampTest() {
}

@Test
void microsecondTimestampTest() {
void rebaseDaysToGregorianTest() {
try (ColumnVector input = ColumnVector.timestampDaysFromBoxedInts(-719164, -354280, null,
-141704, -141428, -141427,
null, null,
-141427, -141427, -31463, -31453, -1, 0, 18335);
ColumnVector expected = ColumnVector.timestampDaysFromBoxedInts(-719162, -354285, null,
-141714, -141438, -141427,
null, null,
-141427, -141427, -31463, -31453, -1, 0, 18335);
ColumnVector result = DateTimeRebase.rebaseJulianToGregorian(input)) {
assertColumnsAreEqual(expected, result);
}
}

@Test
void rebaseMicroToJulian() {
try (ColumnVector input = ColumnVector.timestampMicroSecondsFromBoxedLongs(-62135593076345679L,
-30610213078876544L,
null,
-12244061221876544L,
-12220243200000000L,
-12219639001448163L,
-12219292799000001L,
-45446999900L,
1L,
Expand All @@ -56,6 +72,7 @@ void microsecondTimestampTest() {
null,
-12243197221876544L,
-12219379200000000L,
-12219207001448163L,
-12219292799000001L,
-45446999900L,
1L,
Expand All @@ -65,4 +82,34 @@ void microsecondTimestampTest() {
assertColumnsAreEqual(expected, result);
}
}

@Test
void rebaseMicroToGregorian() {
try (ColumnVector input = ColumnVector.timestampMicroSecondsFromBoxedLongs(-62135765876345679L,
-30609781078876544L,
null,
-12243197221876544L,
-12219379200000000L,
-12219207001448163L,
-12219292799000001L,
-45446999900L,
1L,
null,
1584178381500000L);
ColumnVector expected =
ColumnVector.timestampMicroSecondsFromBoxedLongs(-62135593076345679L,
-30610213078876544L,
null,
-12244061221876544L,
-12220243200000000L,
-12219207001448163L,
-12219292799000001L,
-45446999900L,
1L,
null,
1584178381500000L);
ColumnVector result = DateTimeRebase.rebaseJulianToGregorian(input)) {
assertColumnsAreEqual(expected, result);
}
}
}

0 comments on commit 112b261

Please sign in to comment.