chamikaramj commented on a change in pull request #17038: URL: https://github.com/apache/beam/pull/17038#discussion_r828338310
########## File path: sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOStorageWriteIT.java ########## @@ -0,0 +1,130 @@ +/* + * 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.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.api.services.bigquery.model.QueryResponse; +import com.google.api.services.bigquery.model.TableFieldSchema; +import com.google.api.services.bigquery.model.TableRow; +import com.google.api.services.bigquery.model.TableSchema; +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.extensions.gcp.options.GcpOptions; +import org.apache.beam.sdk.io.GenerateSequence; +import org.apache.beam.sdk.io.gcp.testing.BigqueryClient; +import org.apache.beam.sdk.options.PipelineOptionsFactory; +import org.apache.beam.sdk.testing.TestPipeline; +import org.apache.beam.sdk.transforms.DoFn; +import org.apache.beam.sdk.transforms.ParDo; +import org.apache.beam.sdk.transforms.SerializableFunction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Integration tests for {@link + * org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO#write(SerializableFunction)}. This test writes + * 30MB data to BQ and verify the written row count. + */ +@RunWith(JUnit4.class) +public class BigQueryIOStorageWriteIT { + + private enum WriteMode { + EXACT_ONCE, + AT_LEAST_ONCE + }; + + private String project; + private static final String DATASET_ID = "big_query_storage"; + private static final String TABLE_PREFIX = "storage_write_"; + + private BigQueryOptions bqOptions; + private static final BigqueryClient BQ_CLIENT = new BigqueryClient("BigQueryStorageIOWriteIT"); + + private void setUpTestEnvironment(WriteMode writeMode) { + PipelineOptionsFactory.register(BigQueryOptions.class); + bqOptions = TestPipeline.testingPipelineOptions().as(BigQueryOptions.class); + bqOptions.setProject(TestPipeline.testingPipelineOptions().as(GcpOptions.class).getProject()); + bqOptions.setUseStorageWriteApi(true); + if (writeMode == WriteMode.AT_LEAST_ONCE) { + bqOptions.setUseStorageWriteApiAtLeastOnce(true); + } + bqOptions.setNumStorageWriteApiStreams(2); Review comment: I think options "setNumStorageWriteApiStreams" and "setStorageWriteApiTriggeringFrequencySec" are only intended for unbounded input (in streaming pipelines). @reuvenlax should this have resulted in a validation failure ? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
