@ Nullable private Object getTypedCellValue ( TableFieldSchema fieldSchema , Object v ) { if ( Data . isNull ( v ) ) { return null ; } if ( Objects . equals ( fieldSchema . getMode ( ) , "REPEATED" ) ) { TableFieldSchema elementSchema = fieldSchema . clone ( ) . setMode ( "REQUIRED" ) ; @ SuppressWarnings ( "unchecked" ) List < Map < String , Object > > rawCells = ( List < Map < String , Object > > ) v ; ImmutableList . Builder < Object > values = ImmutableList . builder ( ) ; for ( Map < String , Object > element : rawCells ) { values . add ( getTypedCellValue ( elementSchema , element . get ( "v" ) ) ) ; } return values . build ( ) ; } if ( fieldSchema . getType ( ) . equals ( "RECORD" ) ) { @ SuppressWarnings ( "unchecked" ) Map < String , Object > typedV = ( Map < String , Object > ) v ; return getTypedTableRow ( fieldSchema . getFields ( ) , typedV ) ; } if ( fieldSchema . getType ( ) . equals ( "FLOAT" ) ) { return Double . parseDouble ( ( String ) v ) ; } if ( fieldSchema . getType ( ) . equals ( "BOOLEAN" ) ) { return Boolean . parseBoolean ( ( String ) v ) ; } if ( fieldSchema . getType ( ) . equals ( "TIMESTAMP" ) ) { return formatTimestamp ( ( String ) v ) ; } // Returns the original value for: // 1. String, 2. base64 encoded BYTES, 3. DATE, DATETIME, TIME strings. return v ; }
Adjusts a field returned from the BigQuery API to match what we will receive when running BigQuery s export - to - GCS and parallel read which is the efficient parallel implementation used for batch jobs executed on the Beam Runners that perform initial splitting .