You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "jonathan-lemos (via GitHub)" <gi...@apache.org> on 2023/05/24 20:24:25 UTC

[GitHub] [beam] jonathan-lemos commented on a diff in pull request #26873: Fix ClassCastException in toBeamValue with List<{Primitive}> types

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


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java:
##########
@@ -694,7 +694,7 @@ 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 ? ((Map<String, Object>) v).get("v") : v)

Review Comment:
   I have covered this case.
   Interestingly, it doesn't look like BigQuery supports a Map type (https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#data_type_sizes), so I don't know how to test this path.



##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryUtils.java:
##########
@@ -694,7 +694,7 @@ 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 ? ((Map<String, Object>) v).get("v") : v)

Review Comment:
   I have covered this case in the latest commit.
   Interestingly, it doesn't look like BigQuery supports a Map type (https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#data_type_sizes), so I don't know how to test this path.



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org