jonathan-lemos commented on code in PR #26873:
URL: https://github.com/apache/beam/pull/26873#discussion_r1207255593


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java:
##########
@@ -694,7 +694,15 @@ public static Row toBeamRow(Schema rowSchema, TableSchema 
bqSchema, TableRow jso
     if (jsonBQValue instanceof List) {
       return ((List<Object>) jsonBQValue)
           .stream()
-              .map(v -> ((Map<String, Object>) v).get("v"))
+              .map(
+                  v ->
+                      (v instanceof Map
+                              && !fieldType
+                                  .getCollectionElementType()

Review Comment:
   `fieldType.getCollectionElementType()` should only return `null` if the 
fieldType is not a collection, but the `if (jsonBQValue instanceof List)` case 
should cover that scenario. However, there's nothing stopping someone from 
passing in a non-collection FieldType with a List value, so my latest changes 
show a more helpful error message in that case.
   
   I've extracted the 
`!fieldType.getCollectionElementType().getTypeName().equals(TypeName.MAP)` to a 
variable outside of the lambda.



-- 
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]

Reply via email to