Skip to content

Commit d912aa3

Browse files
committed
fix(avro_to_beam): parse negative int failed
1 parent 25d5431 commit d912aa3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: sdks/java/core/src/main/java/org/apache/beam/sdk/util/VarInt.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static void encode(long v, OutputStream stream) throws IOException {
102102
/** Decodes an integer value from the given stream. */
103103
public static int decodeInt(InputStream stream) throws IOException {
104104
long r = decodeLong(stream);
105-
if (r < 0 || r >= 1L << 32) {
105+
if (r >= 1L << 32) {
106106
throw new IOException("varint overflow " + r);
107107
}
108108
return (int) r;

Diff for: sdks/python/apache_beam/io/avroio.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,9 @@ def avro_atomic_value_to_beam_atomic_value(avro_type: str, value):
646646
if value is None:
647647
return value
648648
elif avro_type == "int":
649-
return ctypes.c_uint32(value).value
649+
return ctypes.c_int32(value).value
650650
elif avro_type == "long":
651-
return ctypes.c_uint64(value).value
651+
return ctypes.c_int64(value).value
652652
else:
653653
return value
654654

0 commit comments

Comments
 (0)