AvroUtils

Utility library to convert struct to BigQuery compatible json based on avro schema

Avro Type Conversion

Primitive Types

AvroBigQuery
nullnot supported
booleanBOOLEAN
intINTEGER
longINTEGER
floatFLOAT
doubleFLOAT
bytesBYTES
stringSTRING

Complex Types

AvroBigQuery
recordRECORD
enumSTRING
arrayREPEATED
mapREAPEATED RECORD with key and value
uniononly supports union with max 2 options and max 1 non nullable type.
fixedBYTES

Logical Types

AvroBigQuery
time-millisTIME
time-microsTIME
timestamp-millisTIMESTAMP
timestamp-microsTIMESTAMP

bq.transform

AvroBigQuery
{"name": "created_at", "type": { "type": "string", "bq.transform": "iso8601_to_timestamp" }}{ "mode": "REQUIRED", "name": "created_at", "type": "TIMESTAMP" }
{"name": "detail","type": { "type": "string", "bq.transform": "any_to_json" }}{ "mode": "REQUIRED", "name": "detail", "type": "STRING" }

bq.source_name

AvroBigQuery
{"name": "full_name","type": { "type": "string", "bq.source_name": "full-name" }}{ "mode": "REQUIRED", "name": "full_name", "type": "STRING" }