Skip to content

Commit b952654

Browse files
committed
update testTimestampParsing
1 parent b12e7ef commit b952654

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

gateway-ha/src/test/java/io/trino/gateway/ha/router/BaseTestQueryHistoryManager.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.junit.jupiter.api.TestInstance.Lifecycle;
2525
import org.testcontainers.containers.JdbcDatabaseContainer;
2626

27+
import java.math.BigDecimal;
2728
import java.util.List;
2829
import java.util.Optional;
2930

@@ -117,16 +118,17 @@ void testFindDistribution()
117118
@Test
118119
void testTimestampParsing()
119120
{
120-
long result = 30338640;
121+
// This ensures odd-minute values remain precision when converted from different formats.
122+
long result = 30338641;
121123

122-
// postgres: minute -> {Double@9333} 3.033864E7
123-
String postgresTimestamp = "3.033864E7";
124-
long parsedLongTimestamp = (long) Float.parseFloat(postgresTimestamp);
124+
// postgres: minute -> {Double@9333} 3.0338641E7
125+
String postgresTimestamp = "3.0338641E7";
126+
long parsedLongTimestamp = new BigDecimal(postgresTimestamp).longValue();
125127
assertThat(parsedLongTimestamp).isEqualTo(result);
126128

127-
// mysql: minute -> {BigDecimal@9775} "30338640"
128-
String mysqlTimestamp = "30338640";
129-
long parsedLongTimestamp2 = (long) Float.parseFloat(mysqlTimestamp);
129+
// mysql: minute -> {BigDecimal@9775} "30338641"
130+
String mysqlTimestamp = "30338641";
131+
long parsedLongTimestamp2 = new BigDecimal(mysqlTimestamp).longValue();
130132
assertThat(parsedLongTimestamp2).isEqualTo(result);
131133
}
132134
}

0 commit comments

Comments
 (0)