use of org.apache.beam.examples.snippets.transforms.io.gcp.bigquery.BigQueryMyData.MyData in project beam by apache.
the class BigQuerySamplesIT method fieldValueListToStrings.
private static List<String> fieldValueListToStrings(FieldValueList row) {
MyData data = new MyData();
data.myString = row.get("string_field").getStringValue();
data.myInt64 = row.get("int64_field").getLongValue();
data.myFloat64 = row.get("float64_field").getDoubleValue();
data.myNumeric = new BigDecimal(row.get("numeric_field").getDoubleValue());
data.myBoolean = row.get("bool_field").getBooleanValue();
data.myBytes = Base64.getDecoder().decode(row.get("bytes_field").getStringValue());
data.myDate = LocalDate.parse(row.get("date_field").getStringValue()).toString();
data.myDateTime = LocalDateTime.parse(row.get("datetime_field").getStringValue()).toString();
data.myTime = LocalTime.parse(row.get("time_field").getStringValue()).toString();
data.myTimestamp = Instant.ofEpochMilli((long) (Double.parseDouble(row.get("timestamp_field").getStringValue()) * 1000.0)).toString();
data.myGeography = row.get("geography_field").getStringValue();
data.myArray = row.get("array_field").getRepeatedValue().stream().map(FieldValue::getLongValue).collect(Collectors.toList());
FieldValueList structValues = row.get("struct_field").getRecordValue();
data.myStruct = new MyStruct();
data.myStruct.stringValue = structValues.get(0).getStringValue();
data.myStruct.int64Value = structValues.get(1).getLongValue();
return myDataToStrings(data);
}
Aggregations