Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Issues with TimeStamp when used for RDS that is backed by PostgreSQL

Aperta
#12 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
aws, java, postgresql
Ambito
api, databases

Direzione di ricerca

Iniziare con la DateTimeParseException in TypeConverter.java:123 e tracciare il modo in cui ExecutionResult.java:132 converte i campi timestamp restituiti. Riprodurre il valore PostgreSQL/RDS con due cifre frazionarie, quindi aggiungere un test di regressione per il parsing; il supporto richiesto per Instant e java.sql.Timestamp dovrebbe essere valutato separatamente prima di considerarlo completato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Java
Stelle
21
Fork
5
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di awslabs/rds-data-api-client-library-java

Tutte le issue di awslabs/rds-data-api-client-library-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.