You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/07/25 09:35:21 UTC

[GitHub] [beam] manitgupta opened a new pull request, #22428: Add units tests for SpannerIO

manitgupta opened a new pull request, #22428:
URL: https://github.com/apache/beam/pull/22428

   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] chamikaramj commented on pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
chamikaramj commented on PR #22428:
URL: https://github.com/apache/beam/pull/22428#issuecomment-1211352065

   https://github.com/apache/beam/pull/22677


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] darshan-sj commented on a diff in pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
darshan-sj commented on code in PR #22428:
URL: https://github.com/apache/beam/pull/22428#discussion_r936934221


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtilsTest.java:
##########
@@ -235,10 +311,42 @@ private static Mutation createMutation(Mutation.Op operation) {
         .to(Struct.newBuilder().set("int64").to(3L).build())
         .set("f_array")
         .toInt64Array(ImmutableList.of(2L, 3L))
+        .set("f_double_array")
+        .toFloat64Array(ImmutableList.of(1., 2.))
+        .set("f_decimal_array")
+        .toNumericArray(
+            ImmutableList.of(
+                BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MAX_VALUE)))
+        .set("f_boolean_array")
+        .toBoolArray(ImmutableList.of(false, true))
+        .set("f_string_array")
+        .toStringArray(ImmutableList.of("donald_duck", "micky_mouse"))
+        .set("f_bytes_array")
+        .toBytesArray(
+            ImmutableList.of(
+                ByteArray.copyFrom("some_bytes".getBytes(UTF_8)),
+                ByteArray.copyFrom("some_bytes".getBytes(UTF_8))))
+        .set("f_datetime_array")
+        .toTimestampArray(
+            ImmutableList.of(
+                Timestamp.parseTimestamp("2077-10-15T00:00:00Z"),

Review Comment:
   Same comment here. Does this produce different output based on machine timezone? I mean the test should not be flaky.



##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtilsTest.java:
##########
@@ -70,11 +83,47 @@ public class MutationUtilsTest {
           .withFieldValue("f_struct", EMPTY_ROW)
           .withFieldValue("f_struct_int64", INT64_ROW)
           .withFieldValue("f_array", ImmutableList.of(2L, 3L))
+          .withFieldValue("f_double_array", ImmutableList.of(1., 2.))
+          .withFieldValue(
+              "f_decimal_array",
+              ImmutableList.of(
+                  BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MAX_VALUE)))
+          .withFieldValue("f_boolean_array", ImmutableList.of(false, true))
+          .withFieldValue("f_string_array", ImmutableList.of("donald_duck", "micky_mouse"))
+          .withFieldValue(
+              "f_bytes_array",
+              ImmutableList.of("some_bytes".getBytes(UTF_8), "some_bytes".getBytes(UTF_8)))
+          .withFieldValue(
+              "f_datetime_array",
+              ImmutableList.of(
+                  DateTime.parse("2077-10-15T00:00:00+00:00"),

Review Comment:
   Does this parse method produce different output based on the timezone of machine it is running on?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] manitgupta commented on pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
manitgupta commented on PR #22428:
URL: https://github.com/apache/beam/pull/22428#issuecomment-1193863964

   R: @darshan-sj


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] manitgupta commented on pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
manitgupta commented on PR #22428:
URL: https://github.com/apache/beam/pull/22428#issuecomment-1208875551

   R: @pabloem 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] manitgupta commented on a diff in pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
manitgupta commented on code in PR #22428:
URL: https://github.com/apache/beam/pull/22428#discussion_r939874937


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtilsTest.java:
##########
@@ -70,11 +83,47 @@ public class MutationUtilsTest {
           .withFieldValue("f_struct", EMPTY_ROW)
           .withFieldValue("f_struct_int64", INT64_ROW)
           .withFieldValue("f_array", ImmutableList.of(2L, 3L))
+          .withFieldValue("f_double_array", ImmutableList.of(1., 2.))
+          .withFieldValue(
+              "f_decimal_array",
+              ImmutableList.of(
+                  BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MAX_VALUE)))
+          .withFieldValue("f_boolean_array", ImmutableList.of(false, true))
+          .withFieldValue("f_string_array", ImmutableList.of("donald_duck", "micky_mouse"))
+          .withFieldValue(
+              "f_bytes_array",
+              ImmutableList.of("some_bytes".getBytes(UTF_8), "some_bytes".getBytes(UTF_8)))
+          .withFieldValue(
+              "f_datetime_array",
+              ImmutableList.of(
+                  DateTime.parse("2077-10-15T00:00:00+00:00"),

Review Comment:
   The string provided fully specified the date, time and the offset (`+00:00`) as per `ISO 8601` standard. So this won't be machine dependent. 
   I also checked this by verifying that other existing unit tests use the same conversion logic. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] chamikaramj commented on a diff in pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
chamikaramj commented on code in PR #22428:
URL: https://github.com/apache/beam/pull/22428#discussion_r942955739


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/SpannerTransformRegistrarTest.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.gcp.spanner;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.google.cloud.Timestamp;
+import com.google.cloud.spanner.TimestampBound;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+import org.apache.beam.sdk.io.gcp.spanner.SpannerTransformRegistrar.InsertBuilder;
+import org.apache.beam.sdk.io.gcp.spanner.SpannerTransformRegistrar.ReadBuilder;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.SchemaTranslation;
+import org.apache.beam.sdk.transforms.ExternalTransformBuilder;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.values.PBegin;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PDone;
+import org.apache.beam.sdk.values.Row;
+import org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException;

Review Comment:
   Probably should be using "com.google.protobuf.InvalidProtocolBufferException"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] chamikaramj commented on a diff in pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
chamikaramj commented on code in PR #22428:
URL: https://github.com/apache/beam/pull/22428#discussion_r942985493


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/SpannerTransformRegistrarTest.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.gcp.spanner;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.google.cloud.Timestamp;
+import com.google.cloud.spanner.TimestampBound;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+import org.apache.beam.sdk.io.gcp.spanner.SpannerTransformRegistrar.InsertBuilder;
+import org.apache.beam.sdk.io.gcp.spanner.SpannerTransformRegistrar.ReadBuilder;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.SchemaTranslation;
+import org.apache.beam.sdk.transforms.ExternalTransformBuilder;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.values.PBegin;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PDone;
+import org.apache.beam.sdk.values.Row;
+import org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException;

Review Comment:
   Nvm, seems like this file was somehow forgotten in https://github.com/apache/beam/commit/434427e90b55027c5944fa73de68bff4f9a4e8fe
   
   Updated by https://github.com/apache/beam/pull/22677



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] manitgupta commented on a diff in pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
manitgupta commented on code in PR #22428:
URL: https://github.com/apache/beam/pull/22428#discussion_r939878432


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtilsTest.java:
##########
@@ -235,10 +311,42 @@ private static Mutation createMutation(Mutation.Op operation) {
         .to(Struct.newBuilder().set("int64").to(3L).build())
         .set("f_array")
         .toInt64Array(ImmutableList.of(2L, 3L))
+        .set("f_double_array")
+        .toFloat64Array(ImmutableList.of(1., 2.))
+        .set("f_decimal_array")
+        .toNumericArray(
+            ImmutableList.of(
+                BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MAX_VALUE)))
+        .set("f_boolean_array")
+        .toBoolArray(ImmutableList.of(false, true))
+        .set("f_string_array")
+        .toStringArray(ImmutableList.of("donald_duck", "micky_mouse"))
+        .set("f_bytes_array")
+        .toBytesArray(
+            ImmutableList.of(
+                ByteArray.copyFrom("some_bytes".getBytes(UTF_8)),
+                ByteArray.copyFrom("some_bytes".getBytes(UTF_8))))
+        .set("f_datetime_array")
+        .toTimestampArray(
+            ImmutableList.of(
+                Timestamp.parseTimestamp("2077-10-15T00:00:00Z"),

Review Comment:
   This string is as per the `RFC 3399` format. It specifies a fully qualified date string with date, time and offset (`Z` translates to UTC+0). Since there is no ambiguity in the specification, it won't be dependent on machine timezone. 
   Also verified by checking usage in other existing unit tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] chamikaramj commented on pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
chamikaramj commented on PR #22428:
URL: https://github.com/apache/beam/pull/22428#issuecomment-1211343357

   Seems like this is causing a breakage for Beam CI: https://scans.gradle.com/s/jf7nk6gl5j4zs/console-log?task=:sdks:java:io:google-cloud-platform:compileTestJava
   
   Can we rollback ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #22428:
URL: https://github.com/apache/beam/pull/22428#issuecomment-1193867378

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] pabloem commented on pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
pabloem commented on PR #22428:
URL: https://github.com/apache/beam/pull/22428#issuecomment-1208897175

   LGTM thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] pabloem merged pull request #22428: Add units tests for SpannerIO

Posted by GitBox <gi...@apache.org>.
pabloem merged PR #22428:
URL: https://github.com/apache/beam/pull/22428


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org