Skip to content
/ beam Public
forked from apache/beam

Commit

Permalink
Fix Java standard coder test
Browse files Browse the repository at this point in the history
  • Loading branch information
Abacn committed Aug 26, 2022
1 parent 33595f0 commit e40ece1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ coder:
# f_timestamp: logical(millis_instant), f_string: string, f_int: int64
payload: "\n:\n\x0bf_timestamp\x1a+:)\n#beam:logical_type:millis_instant:v1\x1a\x02\x10\x04\n\x0e\n\x08f_string\x1a\x02\x10\x07\n\x0b\n\x05f_int\x1a\x02\x10\x04\x12$80be749a-5700-4ede-89d8-dd9a4433a3f8"
examples:
"\x03\x00\x80\x00\x01s\xe8+\xd7k\x182020-08-13T14:14:14.123Z\xeb\xae\xaf\xc1\xbe.": {f_timestamp: 1597328054123, f_string: "2020-08-13T14:14:14.123Z", f_int: 1597328054123}
"\x03\x00\x80\x00\x01s\xe8+\xd7k\x182020-08-13T14:14:14.123Z\xeb\xae\xaf\xc1\xbe.": {f_timestamp: -9223370439526721685, f_string: "2020-08-13T14:14:14.123Z", f_int: 1597328054123}

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ private static Object parseField(Object value, Schema.FieldType fieldType) {
return (String) value;
case BOOLEAN:
return (Boolean) value;
case DATETIME:
// convert shifted millis to epoch millis as in InstantCoder
return new Instant((Long) value + -9223372036854775808L);
case BYTES:
// extract String as byte[]
return ((String) value).getBytes(StandardCharsets.ISO_8859_1);
Expand Down Expand Up @@ -465,7 +468,7 @@ private static Object parseField(Object value, Schema.FieldType fieldType) {
return fieldType
.getLogicalType()
.toInputType(parseField(value, fieldType.getLogicalType().getBaseType()));
default: // DECIMAL, DATETIME
default: // DECIMAL
throw new IllegalArgumentException("Unsupported type name: " + fieldType.getTypeName());
}
}
Expand Down

0 comments on commit e40ece1

Please sign in to comment.