[
https://issues.apache.org/jira/browse/BEAM-6841?focusedWorklogId=220130&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-220130
]
ASF GitHub Bot logged work on BEAM-6841:
----------------------------------------
Author: ASF GitHub Bot
Created on: 28/Mar/19 16:44
Start Date: 28/Mar/19 16:44
Worklog Time Spent: 10m
Work Description: kmjung commented on pull request #8061: [BEAM-6841] Add
support for reading query results using the BigQuery storage API.
URL: https://github.com/apache/beam/pull/8061#discussion_r270097309
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryStorageQuerySource.java
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.bigquery;
+
+import static
org.apache.beam.vendor.guava.v20_0.com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.api.services.bigquery.model.Table;
+import com.google.api.services.bigquery.model.TableReference;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nullable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.QueryPriority;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.sdk.options.ValueProvider;
+import org.apache.beam.sdk.transforms.SerializableFunction;
+import org.apache.beam.sdk.transforms.display.DisplayData;
+
+/** A {@link org.apache.beam.sdk.io.Source} representing reading the results
of a query. */
+@Experimental(Experimental.Kind.SOURCE_SINK)
+public class BigQueryStorageQuerySource<T> extends
BigQueryStorageSourceBase<T> {
+
+ public static <T> BigQueryStorageQuerySource<T> create(
+ String stepUuid,
+ ValueProvider<String> queryProvider,
+ Boolean flattenResults,
+ Boolean useLegacySql,
+ QueryPriority priority,
+ @Nullable String location,
+ @Nullable String kmsKey,
+ SerializableFunction<SchemaAndRecord, T> parseFn,
+ Coder<T> outputCoder,
+ BigQueryServices bqServices) {
+ return new BigQueryStorageQuerySource<>(
+ stepUuid,
+ queryProvider,
+ flattenResults,
+ useLegacySql,
+ priority,
+ location,
+ kmsKey,
+ parseFn,
+ outputCoder,
+ bqServices);
+ }
+
+ private final String stepUuid;
+ private final ValueProvider<String> queryProvider;
+ private final Boolean flattenResults;
+ private final Boolean useLegacySql;
+ private final QueryPriority priority;
+ private final String location;
+ private final String kmsKey;
+
+ private transient AtomicReference<BigQueryQueryHelper> queryHelperReference;
+
+ private BigQueryStorageQuerySource(
+ String stepUuid,
+ ValueProvider<String> queryProvider,
+ Boolean flattenResults,
+ Boolean useLegacySql,
+ QueryPriority priority,
+ @Nullable String location,
+ @Nullable String kmsKey,
+ SerializableFunction<SchemaAndRecord, T> parseFn,
+ Coder<T> outputCoder,
+ BigQueryServices bqServices) {
+ super(null, parseFn, outputCoder, bqServices);
+ this.stepUuid = checkNotNull(stepUuid, "stepUuid");
+ this.queryProvider = checkNotNull(queryProvider, "queryProvider");
+ this.flattenResults = checkNotNull(flattenResults, "flattenResults");
+ this.useLegacySql = checkNotNull(useLegacySql, "useLegacySql");
+ this.priority = checkNotNull(priority, "priority");
+ this.location = location;
+ this.kmsKey = kmsKey;
+ this.queryHelperReference = new AtomicReference<>();
+ }
+
+ private void readObject(ObjectInputStream in) throws ClassNotFoundException,
IOException {
+ in.defaultReadObject();
Review comment:
Done.
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 220130)
Time Spent: 4h 50m (was: 4h 40m)
> Support reading query results with the BigQuery storage API
> -----------------------------------------------------------
>
> Key: BEAM-6841
> URL: https://issues.apache.org/jira/browse/BEAM-6841
> Project: Beam
> Issue Type: New Feature
> Components: io-java-gcp
> Reporter: Kenneth Jung
> Assignee: Kenneth Jung
> Priority: Minor
> Time Spent: 4h 50m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)