@@ -160,7 +160,7 @@ public void testDatetimeWithNanos() throws IOException, SQLException {
160
160
versionSupportsDateNanos ()
161
161
);
162
162
163
- long randomTimestampWitnNanos = randomTimeInNanos ();
163
+ long randomTimestampWitnNanos = randomTimestampWithNanos ();
164
164
int randomNanosOnly = extractNanosOnly (randomTimestampWitnNanos );
165
165
setupIndexForDateTimeTestsWithNanos (randomTimestampWitnNanos );
166
166
@@ -192,7 +192,7 @@ public void testDateTimeWithNanosAgainstDriverWithoutSupport() throws IOExceptio
192
192
versionSupportsDateNanos ()
193
193
);
194
194
195
- long randomTimestampWitnNanos = randomTimeInNanos ();
195
+ long randomTimestampWitnNanos = randomTimestampWithNanos ();
196
196
int randomNanosOnly = extractNanosOnly (randomTimestampWitnNanos );
197
197
setupIndexForDateTimeTestsWithNanos (randomTimestampWitnNanos );
198
198
@@ -215,6 +215,14 @@ public void testDateTimeWithNanosAgainstDriverWithoutSupport() throws IOExceptio
215
215
}
216
216
}
217
217
218
+ private static long randomTimestampWithNanos () {
219
+ long randomTimestampWithNanos = randomTimeInNanos ();
220
+ // Indexing will jiggle the value by adding -1, 0, 1. The query will truncate it from ns to ms and expect no match. If the
221
+ // jiggled value will round to no sub-ms fraction, the query will match. So ensure that won't happen.
222
+ randomTimestampWithNanos += (randomTimestampWithNanos % 1_000_000 < 10 ) ? 10 : 0 ;
223
+ return randomTimestampWithNanos ;
224
+ }
225
+
218
226
public void testDate () throws IOException , SQLException {
219
227
long randomMillis = randomLongBetween (1 , DateUtils .MAX_MILLIS_BEFORE_9999 );
220
228
setupIndexForDateTimeTests (randomMillis );
0 commit comments