[
https://issues.apache.org/jira/browse/BEAM-5782?focusedWorklogId=156183&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-156183
]
ASF GitHub Bot logged work on BEAM-5782:
----------------------------------------
Author: ASF GitHub Bot
Created on: 18/Oct/18 23:52
Start Date: 18/Oct/18 23:52
Worklog Time Spent: 10m
Work Description: lukecwik closed pull request #6729: [BEAM-5782] Make
TableRows cloneable when read from Avro files.
URL: https://github.com/apache/beam/pull/6729
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java
index 4874f887176..e620e403c6c 100644
---
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java
+++
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java
@@ -25,7 +25,6 @@
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 com.google.common.collect.ImmutableMap;
import com.google.common.io.BaseEncoding;
import java.math.BigDecimal;
@@ -156,17 +155,17 @@ private static Object getTypedCellValue(Schema schema,
TableFieldSchema fieldSch
// REPEATED fields are represented as Avro arrays.
if (v == null) {
// Handle the case of an empty repeated field.
- return ImmutableList.of();
+ return new ArrayList<>();
}
@SuppressWarnings("unchecked")
List<Object> elements = (List<Object>) v;
- ImmutableList.Builder<Object> values = ImmutableList.builder();
+ ArrayList<Object> values = new ArrayList<>();
Type elementType = schema.getElementType().getType();
LogicalType elementLogicalType = schema.getElementType().getLogicalType();
for (Object element : elements) {
values.add(convertRequiredField(elementType, elementLogicalType,
fieldSchema, element));
}
- return values.build();
+ return values;
}
private static Object convertRequiredField(
diff --git
a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtilsTest.java
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtilsTest.java
index 236f22ebc08..e0d0891ab9a 100644
---
a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtilsTest.java
+++
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtilsTest.java
@@ -134,6 +134,8 @@ public void testConvertGenericRecordToTableRow() throws
Exception {
TableRow convertedRow =
BigQueryAvroUtils.convertGenericRecordToTableRow(record, tableSchema);
TableRow row = new TableRow().set("number", "5").set("associates", new
ArrayList<TableRow>());
assertEquals(row, convertedRow);
+ TableRow clonedRow = convertedRow.clone();
+ assertEquals(convertedRow, clonedRow);
}
{
// Test type conversion for:
@@ -164,6 +166,8 @@ public void testConvertGenericRecordToTableRow() throws
Exception {
.set("anniversaryDate", "2000-01-01")
.set("anniversaryDatetime", "2000-01-01 00:00:00.000005")
.set("anniversaryTime", "00:00:00.000005");
+ TableRow clonedRow = convertedRow.clone();
+ assertEquals(convertedRow, clonedRow);
assertEquals(row, convertedRow);
}
{
@@ -182,6 +186,8 @@ public void testConvertGenericRecordToTableRow() throws
Exception {
.set("number", "5")
.set("birthdayMoney", birthdayMoney.toString());
assertEquals(row, convertedRow);
+ TableRow clonedRow = convertedRow.clone();
+ assertEquals(convertedRow, clonedRow);
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 156183)
Time Spent: 40m (was: 0.5h)
> BigQuery TableRows not cloneable when using Dataflow
> ----------------------------------------------------
>
> Key: BEAM-5782
> URL: https://issues.apache.org/jira/browse/BEAM-5782
> Project: Beam
> Issue Type: Bug
> Components: io-java-gcp
> Reporter: Luke Cwik
> Assignee: Luke Cwik
> Priority: Minor
> Fix For: 2.9.0
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> TableRows are expected to be cloneable.
> BigQueryAvroUtils converts repeated records using an ImmutableList which is
> not cloneable.
>
> Reproduction steps:
> 1. Clone the code
> [https://github.com/nahuellofeudo/row-clone-poc.git|https://www.google.com/url?q=https://github.com/nahuellofeudo/row-clone-poc.git&sa=D&usg=AFQjCNGkT0bYzhAoozGTQ4vsizxtphxj-g]
> 2. Run on Dataflow:
> mvn clean compile exec:java
> -Dexec.mainClass=org.apache.beam.examples.RowClonePoc \
> -Dexec.args="--runner=DataflowRunner
> --gcpTempLocation=gs://<GCS_TEMP_FOLDER> \
> --tempLocation=gs://<GCS_TEMP_FOLDER> --project=<PROJECT_ID>"
> -Pdataflow-runner
> 3. Run locally:
> mvn clean compile exec:java
> -Dexec.mainClass=org.apache.beam.examples.RowClonePoc \
> -Dexec.args="--tempLocation=gs://<GCS_TEMP_FOLDER>
> --project=<PROJECT_ID>"
> 4. Job execution on step 2 will fail [1].
> 5. Job execution on step 3 will success [2].
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)