I have a data stream containing Strings which look like JSONArrays. I want to parse those Strings and write to BigQuery table using Apache Beam but am getting an error while writing repeated Strings.
Here´s how I convert my string to TableRow:
String dataString = "[{\"EMAIL\": [\"zog@yahoo.com\"]}]";
JSONArray jsonArray = new JSONArray(dataString);
TableRow tableRow = new TableRow();
for (int i = 0; i < jsonArray.length(); i++) {
JSONArray emailArray = new JSONArray(jsonArray.getJSONObject(i).get("EMAIL").toString());
tableRow.set("EMAIL", emailArray); //Results in error
}
Here´s what my BigQuery schema looks like:
[
{
"name": "EMAIL",
"type": "STRING",
"mode": "REPEATED"
}
]
I have managed to write a similar repeated String to BigQuery table using Python but unable to do it using Apache Beam. I suppose I am not saving the right key-value pair in TableRow. The error I am getting now is:
java.io.IOException: Insert failed: [{"errors":[{"debugInfo":"","location":"email","message":"This field is not a record.","reason":"invalid"}],"index":0}]
I need help regarding how to save a similar repeated String to BigQuery without creating a record and would appreciate any advice or suggestions. Thanks in advance.