Hi there

I'm trying to read rows from a BigQuery table that contains a repeated field 
into POJOs. Unfortunately, I'm running into issues and I can't figure it out.

I have something like this:

@DefaultSchema(JavaFieldSchema.class)
class Article implements Serializable {
  public Long id;
  public String title;
  @SchemaFieldName("author_ids")
  public Long[] authorIds;
}

PCollection<Article> articles = pipeline
  .apply(
    BigQueryIO
      .readTableRowsWithSchema()
      .from("myproject:data_warehouse.articles")
  )
  .apply(Convert.to(Article.class));

The schema looks like this:

[
  {
    "mode": "NULLABLE",
    "name": "id",
    "type": "INTEGER"
  },
  {
    "mode": "NULLABLE",
    "name": "title",
    "type": "STRING"
  },
  {
    "mode": "REPEATED",
    "name": "author_ids",
    "type": "INTEGER"
  }
]

When I run the pipeline, I end up with the following exception:

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map

Should this be possible? Strangely, when I remove the repeated field from the 
schema/POJO it works perfectly.

I'm using Beam SDK 2.19.0 with the direct runner. Any help would be much 
appreciated.

Josh

Reply via email to