This is an automated email from the ASF dual-hosted git repository.
pabloem pushed a commit to branch release-2.6.0
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/release-2.6.0 by this push:
new 29dd649 [BEAM-4862] Fixes bug in Spanner's MutationGroupEncoder by
converting timestamps into Long and not Int.
29dd649 is described below
commit 29dd64913804974f248036535f4c3af4b0dd4ba1
Author: Eric Beach <[email protected]>
AuthorDate: Mon Jul 30 12:24:18 2018 -0400
[BEAM-4862] Fixes bug in Spanner's MutationGroupEncoder by converting
timestamps into Long and not Int.
---
.../sdk/io/gcp/spanner/MutationGroupEncoder.java | 2 +-
.../io/gcp/spanner/MutationGroupEncoderTest.java | 30 ++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoder.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoder.java
index 77ede3e..4c97fac 100644
---
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoder.java
+++
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoder.java
@@ -478,7 +478,7 @@ class MutationGroupEncoder {
if (isNull) {
m.set(fieldName).to((Timestamp) null);
} else {
- int seconds = VarInt.decodeInt(bis);
+ long seconds = VarInt.decodeLong(bis);
int nanoseconds = VarInt.decodeInt(bis);
m.set(fieldName).to(Timestamp.ofTimeSecondsAndNanos(seconds,
nanoseconds));
}
diff --git
a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoderTest.java
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoderTest.java
index 2509f4d..a600551 100644
---
a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoderTest.java
+++
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationGroupEncoderTest.java
@@ -529,6 +529,36 @@ public class MutationGroupEncoderTest {
}
@Test
+ public void decodeBasicTimestampMutationGroup() {
+ SpannerSchema spannerSchemaTimestamp =
+ SpannerSchema.builder().addColumn("timestampTest", "timestamp",
"TIMESTAMP").build();
+ Timestamp timestamp1 = Timestamp.now();
+ Mutation mutation1 =
+
Mutation.newInsertOrUpdateBuilder("timestampTest").set("timestamp").to(timestamp1).build();
+ encodeAndVerify(g(mutation1), spannerSchemaTimestamp);
+
+ Timestamp timestamp2 = Timestamp.parseTimestamp("2001-01-01T00:00:00Z");
+ Mutation mutation2 =
+
Mutation.newInsertOrUpdateBuilder("timestampTest").set("timestamp").to(timestamp2).build();
+ encodeAndVerify(g(mutation2), spannerSchemaTimestamp);
+ }
+
+ @Test
+ public void decodeMinAndMaxTimestampMutationGroup() {
+ SpannerSchema spannerSchemaTimestamp =
+ SpannerSchema.builder().addColumn("timestampTest", "timestamp",
"TIMESTAMP").build();
+ Timestamp timestamp1 = Timestamp.MIN_VALUE;
+ Mutation mutation1 =
+
Mutation.newInsertOrUpdateBuilder("timestampTest").set("timestamp").to(timestamp1).build();
+ encodeAndVerify(g(mutation1), spannerSchemaTimestamp);
+
+ Timestamp timestamp2 = Timestamp.MAX_VALUE;
+ Mutation mutation2 =
+
Mutation.newInsertOrUpdateBuilder("timestampTest").set("timestamp").to(timestamp2).build();
+ encodeAndVerify(g(mutation2), spannerSchemaTimestamp);
+ }
+
+ @Test
public void timestampKeys() throws Exception {
SpannerSchema.Builder builder = SpannerSchema.builder();