Skip to content

Commit 5ec9d4b

Browse files
committed
reusing PICOSECONDS_PER_MILLISECOND constant
1 parent ff07a0e commit 5ec9d4b

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

core/trino-main/src/test/java/io/trino/type/TestLongTimestampWithTimeZoneType.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static io.trino.spi.type.TimeZoneKey.getTimeZoneKeyForOffset;
3131
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MICROS;
3232
import static io.trino.spi.type.TimestampWithTimeZoneType.createTimestampWithTimeZoneType;
33+
import static io.trino.spi.type.Timestamps.PICOSECONDS_PER_MILLISECOND;
3334
import static org.assertj.core.api.Assertions.assertThat;
3435

3536
public class TestLongTimestampWithTimeZoneType
@@ -57,8 +58,6 @@ public static ValueBlock createTestBlock()
5758
return blockBuilder.buildValueBlock();
5859
}
5960

60-
private static final int PICOS_OF_MILLI = 1_000_000_000;
61-
6261
@Override
6362
protected Object getGreaterValue(Object value)
6463
{
@@ -124,22 +123,22 @@ public void testPreviousValueEveryPrecision(int precision, LongTimestampWithTime
124123
LongTimestampWithTimeZone zeroValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(0, 0, UTC_KEY);
125124
LongTimestampWithTimeZone sequenceValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(middleRangeEpochMillis, 0, UTC_KEY);
126125
LongTimestampWithTimeZone nextToMinValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(minValue.getEpochMillis(), step, UTC_KEY);
127-
LongTimestampWithTimeZone previousToMaxValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOS_OF_MILLI - (2 * step), UTC_KEY);
126+
LongTimestampWithTimeZone previousToMaxValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOSECONDS_PER_MILLISECOND - (2 * step), UTC_KEY);
128127

129128
assertThat(type.getPreviousValue(minValue))
130129
.isEqualTo(Optional.empty());
131130
assertThat(type.getPreviousValue(nextToMinValueType))
132131
.isEqualTo(Optional.of(minValue));
133132

134133
assertThat(type.getPreviousValue(zeroValueType))
135-
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(-1, PICOS_OF_MILLI - step, UTC_KEY)));
134+
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(-1, PICOSECONDS_PER_MILLISECOND - step, UTC_KEY)));
136135
assertThat(type.getPreviousValue(sequenceValueType))
137-
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(middleRangeEpochMillis - 1, PICOS_OF_MILLI - step, UTC_KEY)));
136+
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(middleRangeEpochMillis - 1, PICOSECONDS_PER_MILLISECOND - step, UTC_KEY)));
138137

139138
assertThat(type.getPreviousValue(maxValue))
140-
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOS_OF_MILLI - (2 * step), UTC_KEY)));
139+
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOSECONDS_PER_MILLISECOND - (2 * step), UTC_KEY)));
141140
assertThat(type.getPreviousValue(previousToMaxValueType))
142-
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOS_OF_MILLI - (3 * step), UTC_KEY)));
141+
.isEqualTo(Optional.of(LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOSECONDS_PER_MILLISECOND - (3 * step), UTC_KEY)));
143142
}
144143

145144
@ParameterizedTest
@@ -152,7 +151,7 @@ public void testNextValueEveryPrecision(int precision, LongTimestampWithTimeZone
152151
LongTimestampWithTimeZone zeroValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(0, 0, UTC_KEY);
153152
LongTimestampWithTimeZone sequenceValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(middleRangeEpochMillis, 0, UTC_KEY);
154153
LongTimestampWithTimeZone nextToMinValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(minValue.getEpochMillis(), step, UTC_KEY);
155-
LongTimestampWithTimeZone previousToMaxValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOS_OF_MILLI - (2 * step), UTC_KEY);
154+
LongTimestampWithTimeZone previousToMaxValueType = LongTimestampWithTimeZone.fromEpochMillisAndFraction(maxValue.getEpochMillis(), PICOSECONDS_PER_MILLISECOND - (2 * step), UTC_KEY);
156155

157156
assertThat(type.getNextValue(minValue))
158157
.isEqualTo(Optional.of(nextToMinValueType));
@@ -176,47 +175,47 @@ public static Stream<Arguments> testPreviousNextValueEveryPrecisionDataProvider(
176175
Arguments.of(
177176
4,
178177
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
179-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 100_000_000, UTC_KEY),
178+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 100_000_000, UTC_KEY),
180179
100_000_000),
181180
Arguments.of(
182181
5,
183182
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
184-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 10_000_000, UTC_KEY),
183+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 10_000_000, UTC_KEY),
185184
10_000_000),
186185
Arguments.of(
187186
6,
188187
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
189-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 1_000_000, UTC_KEY),
188+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 1_000_000, UTC_KEY),
190189
1_000_000),
191190
Arguments.of(
192191
7,
193192
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
194-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 100_000, UTC_KEY),
193+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 100_000, UTC_KEY),
195194
100_000),
196195
Arguments.of(
197196
8,
198197
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
199-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 10_000, UTC_KEY),
198+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 10_000, UTC_KEY),
200199
10_000),
201200
Arguments.of(
202201
9,
203202
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
204-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 1_000, UTC_KEY),
203+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 1_000, UTC_KEY),
205204
1_000),
206205
Arguments.of(
207206
10,
208207
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
209-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 100, UTC_KEY),
208+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 100, UTC_KEY),
210209
100),
211210
Arguments.of(
212211
11,
213212
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
214-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 10, UTC_KEY),
213+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 10, UTC_KEY),
215214
10),
216215
Arguments.of(
217216
12,
218217
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MIN_VALUE, 0, UTC_KEY),
219-
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOS_OF_MILLI - 1, UTC_KEY),
218+
LongTimestampWithTimeZone.fromEpochMillisAndFraction(Long.MAX_VALUE, PICOSECONDS_PER_MILLISECOND - 1, UTC_KEY),
220219
1));
221220
}
222221

0 commit comments

Comments
 (0)