Issues with TimeStamp when used for RDS that is backed by PostgreSQL
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với DateTimeParseException tại TypeConverter.java:123 và lần theo cách ExecutionResult.java:132 chuyển đổi các trường timestamp được trả về. Tái hiện giá trị PostgreSQL/RDS với hai chữ số phần thập phân, sau đó thêm một regression test cho việc phân tích; khả năng hỗ trợ Instant và java.sql.Timestamp được yêu cầu nên được đánh giá riêng trước khi xem là đã hoàn tất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I created an integration test that uses version 2.0.0 of the ads-data-api-client-library and writes and then retrieves data to a table with a timestamp column..
When retrieving a timestamp value that has millis mod 10 = 0, e.g. 2022-04-06 22:58:48.990 (or as displayed on the RDS query tool in the Aws console 2022-04-06 22:58:48.99), an exception is thrown, like so:
java.time.format.DateTimeParseException: Text '2022-04-06 22:58:48.99' could not be parsed, unparsed text found at index 19
0 = {StackTraceElement@6106} "java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2049)"
1 = {StackTraceElement@6107} "java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1874)"
2 = {StackTraceElement@6108} "com.amazon.rdsdata.client.TypeConverter.fromField(TypeConverter.java:123)"
3 = {StackTraceElement@6109} "com.amazon.rdsdata.client.ExecutionResult$Row.getValue(ExecutionResult.java:132)"
It appears that the parsing format does not properly deal with a date time string that doesn't have the 3rd digit to the right of the decimal place.
I have worked around this by adding one millisecond to date time values for which datetimevalue.toEpochMillis % 10 == 0,
e.g.
fun Instant.asRDSLocalDateTime() : LocalDateTime {
// Kuldge to deal with RDS formatting and parsing - date time values that don't have 3 digits of milli seconds , e.g. 2022-04-06 23:12:00.12 fail to parse due to RDS Client
// example exception: java.time.format.DateTimeParseException: Text '2022-04-06 22:58:48.99' could not be parsed, unparsed text found at index 19
var truncated = this.truncatedTo(ChronoUnit.MILLIS)
if (truncated.toEpochMilli() % 10L == 0L) {
truncated= truncated.plusMillis(1L)
}
return LocalDateTime.ofInstant(truncated,ZoneOffset.UTC)
}
Ever since I did that, I no longer get exceptions.
Should be simple to fix, just change the format string.
While you are in there, could you add support for Instants? Coverting back and forth to LocalDateTime is tedious.
And, while your at it, it would be easier to use the rds-data-api-client-library-java if it supported the java.sql types, e.g. TimeStamp. It would result in less boilerplate.
Thanks
- Ngôn ngữ chính
- Java
- Star
- 21
- Fork
- 5
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của awslabs/rds-data-api-client-library-java
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
awslabs/rds-data-api-client-library-java#11 · 2 bình luận ·
-
aws x-ray compatabilityĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
awslabs/rds-data-api-client-library-java#6 · 1 reaction ·
-
Missing dependenciesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
awslabs/rds-data-api-client-library-java#5 · 4 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
awslabs/rds-data-api-client-library-java#3 · 1 bình luận ·
Tất cả issue của awslabs/rds-data-api-client-library-java
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
commonmark/commonmark-java#460 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
GoogleCloudPlatform/spring-cloud-gcp#4664 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement user story
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100