You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/09/02 13:22:00 UTC

[jira] [Work logged] (BEAM-10139) Add cross-language wrapper for Java's SpannerIO Write

     [ https://issues.apache.org/jira/browse/BEAM-10139?focusedWorklogId=477857&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-477857 ]

ASF GitHub Bot logged work on BEAM-10139:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Sep/20 13:21
            Start Date: 02/Sep/20 13:21
    Worklog Time Spent: 10m 
      Work Description: piotr-szuberski commented on a change in pull request #12611:
URL: https://github.com/apache/beam/pull/12611#discussion_r482063484



##########
File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/StructUtils.java
##########
@@ -0,0 +1,545 @@
+/*
+ * 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 java.util.stream.Collectors.toList;
+import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import com.google.cloud.ByteArray;
+import com.google.cloud.Timestamp;
+import com.google.cloud.spanner.Struct;
+import com.google.cloud.spanner.Type;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.stream.StreamSupport;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.values.Row;
+import org.joda.time.DateTime;
+import org.joda.time.Instant;
+
+final class StructUtils {
+  public static Row translateStructToRow(Struct struct, Schema schema) {
+    checkForSchemasEquality(schema.getFields(), struct.getType().getStructFields(), false);
+
+    List<Schema.Field> fields = schema.getFields();
+    Row.FieldValueBuilder valueBuilder = null;
+    // TODO: Remove this null-checking once nullable fields are supported in cross-language

Review comment:
       NullableCoder is not a standard coder as was mentioned here: https://issues.apache.org/jira/browse/BEAM-10529?jql=project%20%3D%20BEAM%20AND%20text%20~%20%22nullable%20python%22
   So I suppose the only way to support null values is not to set them.
   I noticed that when I tried to read a null field from Spanner table. But I may be wrong




----------------------------------------------------------------
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.

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 477857)
    Time Spent: 1h 40m  (was: 1.5h)

> Add cross-language wrapper for Java's SpannerIO Write
> -----------------------------------------------------
>
>                 Key: BEAM-10139
>                 URL: https://issues.apache.org/jira/browse/BEAM-10139
>             Project: Beam
>          Issue Type: Sub-task
>          Components: cross-language, io-java-gcp, io-py-gcp
>    Affects Versions: Not applicable
>            Reporter: Piotr Szuberski
>            Assignee: Piotr Szuberski
>            Priority: P2
>              Labels: portability
>             Fix For: Not applicable
>
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> Add cross-language wrapper for Java's SpannerIO Write



--
This message was sent by Atlassian Jira
(v8.3.4#803005)