@@ -163,7 +163,7 @@ public void testDatetimeWithNanos() throws IOException, SQLException {
163
163
versionSupportsDateNanos ()
164
164
);
165
165
166
- long randomTimestampWitnNanos = randomTimeInNanos ();
166
+ long randomTimestampWitnNanos = randomTimestampWithNanos ();
167
167
int randomNanosOnly = extractNanosOnly (randomTimestampWitnNanos );
168
168
setupIndexForDateTimeTestsWithNanos (randomTimestampWitnNanos );
169
169
@@ -195,7 +195,7 @@ public void testDateTimeWithNanosAgainstDriverWithoutSupport() throws IOExceptio
195
195
versionSupportsDateNanos ()
196
196
);
197
197
198
- long randomTimestampWitnNanos = randomTimeInNanos ();
198
+ long randomTimestampWitnNanos = randomTimestampWithNanos ();
199
199
int randomNanosOnly = extractNanosOnly (randomTimestampWitnNanos );
200
200
setupIndexForDateTimeTestsWithNanos (randomTimestampWitnNanos );
201
201
@@ -218,6 +218,14 @@ public void testDateTimeWithNanosAgainstDriverWithoutSupport() throws IOExceptio
218
218
}
219
219
}
220
220
221
+ private static long randomTimestampWithNanos () {
222
+ long randomTimestampWithNanos = randomTimeInNanos ();
223
+ // 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
224
+ // jiggled value will round to no sub-ms fraction, the query will match. So ensure that won't happen.
225
+ randomTimestampWithNanos += (randomTimestampWithNanos % 1_000_000 < 10 ) ? 10 : 0 ;
226
+ return randomTimestampWithNanos ;
227
+ }
228
+
221
229
public void testDate () throws IOException , SQLException {
222
230
long randomMillis = randomLongBetween (1 , DateUtils .MAX_MILLIS_BEFORE_9999 );
223
231
setupIndexForDateTimeTests (randomMillis );
0 commit comments