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 2021/04/01 17:15:00 UTC

[jira] [Work logged] (BEAM-8933) BigQuery IO should support reading Arrow format over Storage API

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

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

                Author: ASF GitHub Bot
            Created on: 01/Apr/21 17:14
            Start Date: 01/Apr/21 17:14
    Worklog Time Spent: 10m 
      Work Description: TheNeuralBit commented on a change in pull request #10384:
URL: https://github.com/apache/beam/pull/10384#discussion_r605818919



##########
File path: sdks/java/extensions/arrow/src/main/java/org/apache/beam/sdk/extensions/arrow/ArrowConversion.java
##########
@@ -0,0 +1,448 @@
+/*
+ * 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.extensions.arrow;
+
+import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.VectorSchemaRoot;
+import org.apache.arrow.vector.types.TimeUnit;
+import org.apache.arrow.vector.types.pojo.ArrowType;
+import org.apache.arrow.vector.util.Text;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.schemas.CachingFactory;
+import org.apache.beam.sdk.schemas.Factory;
+import org.apache.beam.sdk.schemas.FieldValueGetter;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.Schema.Field;
+import org.apache.beam.sdk.schemas.Schema.FieldType;
+import org.apache.beam.sdk.schemas.logicaltypes.FixedBytes;
+import org.apache.beam.sdk.values.Row;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+
+/**
+ * Utilities to create {@link Iterable}s of Beam {@link Row} instances backed by Arrow record
+ * batches.
+ */
+@Experimental(Experimental.Kind.SCHEMAS)
+public class ArrowConversion {
+  /** Converts Arrow schema to Beam row schema. */
+  public static Schema toBeamSchema(org.apache.arrow.vector.types.pojo.Schema schema) {
+    return toBeamSchema(schema.getFields());
+  }
+
+  public static Schema toBeamSchema(List<org.apache.arrow.vector.types.pojo.Field> fields) {
+    Schema.Builder builder = Schema.builder();
+    for (org.apache.arrow.vector.types.pojo.Field field : fields) {
+      Field beamField = toBeamField(field);
+      builder.addField(beamField);
+    }
+    return builder.build();
+  }
+
+  /** Get Beam Field from Arrow Field. */
+  private static Field toBeamField(org.apache.arrow.vector.types.pojo.Field field) {
+    FieldType beamFieldType = toFieldType(field.getFieldType(), field.getChildren());

Review comment:
       This is handled in `toFieldType`




-- 
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: 575618)
    Time Spent: 13h 10m  (was: 13h)

> BigQuery IO should support reading Arrow format over Storage API
> ----------------------------------------------------------------
>
>                 Key: BEAM-8933
>                 URL: https://issues.apache.org/jira/browse/BEAM-8933
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-gcp
>            Reporter: Kirill Kozlov
>            Assignee: Isidro Martinez
>            Priority: P3
>          Time Spent: 13h 10m
>  Remaining Estimate: 0h
>
> As of right now BigQuery uses Avro format for reading and writing.
> We should add a config to BigQueryIO to specify which format to use: Arrow or Avro (with Avro as default).



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