robertwb commented on code in PR #32512:
URL: https://github.com/apache/beam/pull/32512#discussion_r1803668792
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProto.java:
##########
@@ -289,25 +307,44 @@ private static Object toProtoValue(
case ROW:
return messageFromBeamRow(fieldDescriptor.getMessageType(), (Row)
value, null, -1);
case ARRAY:
- List<Object> list = (List<Object>) value;
- @Nullable FieldType arrayElementType =
beamFieldType.getCollectionElementType();
- if (arrayElementType == null) {
- throw new RuntimeException("Unexpected null element type!");
- }
- return list.stream()
- .map(v -> toProtoValue(fieldDescriptor, arrayElementType, v))
- .collect(Collectors.toList());
case ITERABLE:
Iterable<Object> iterable = (Iterable<Object>) value;
@Nullable FieldType iterableElementType =
beamFieldType.getCollectionElementType();
if (iterableElementType == null) {
- throw new RuntimeException("Unexpected null element type!");
+ throw new RuntimeException("Unexpected null element type: " +
fieldDescriptor.getName());
}
- return StreamSupport.stream(iterable.spliterator(), false)
- .map(v -> toProtoValue(fieldDescriptor, iterableElementType, v))
- .collect(Collectors.toList());
+ // We currently only support maps as non-row or non-scalar element
types
+ // given that BigQuery does not support nested arrays. If the element
type is of map type
+ // we should flatten it given how is being translated (as a list of
proto(key, value).
Review Comment:
IMHO, if BQ doesn't support arrays of arrays (or arrays of maps) we should
reject such rather than implicitly flattening them (which is lossy and could be
unexpected from a user's perspective).
--
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]