MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / getValueForBigQuery

Function getValueForBigQuery

plugins/destination/bigquery/client/write.go:100–141  ·  view source on GitHub ↗
(col arrow.Array, i int)

Source from the content-addressed store, hash-verified

98}
99
100func getValueForBigQuery(col arrow.Array, i int) any {
101 switch v := col.(type) {
102 case *array.Struct:
103 m := map[string]bigquery.Value{}
104 fields := v.DataType().(*arrow.StructType).Fields()
105 for f, field := range fields {
106 m[field.Name] = getValueForBigQuery(v.Field(f), i)
107 }
108 return m
109 case *array.Map:
110 v2 := col.GetOneForMarshal(i)
111 b, _ := json.Marshal(v2)
112 return string(b)
113 case array.ListLike:
114 col := col.(array.ListLike)
115 from, to := col.ValueOffsets(i)
116 slc := array.NewSlice(col.ListValues(), from, to)
117 elems := make([]any, 0, slc.Len())
118 for j := 0; j < slc.Len(); j++ {
119 if slc.IsNull(j) {
120 // LIMITATION: BigQuery does not support null values in repeated columns.
121 // Therefore, these get stripped out here. In the future, perhaps we should support
122 // an option to use JSON instead of repeated columns for users who need to preserve
123 // the null values.
124 continue
125 }
126 elems = append(elems, getValueForBigQuery(slc, j))
127 }
128 return elems
129 case *array.MonthDayNanoInterval:
130 return v.Value(i)
131 case *array.DayTimeInterval:
132 return v.Value(i)
133 case *array.Duration:
134 return v.Value(i)
135 case *array.Timestamp:
136 return v.Value(i).ToTime(v.DataType().(*arrow.TimestampType).Unit)
137 case *types.JSONArray:
138 return v.ValueStr(i)
139 }
140 return col.GetOneForMarshal(i)
141}

Callers 1

WriteTableBatchMethod · 0.85

Calls 2

ValueMethod · 0.65
ToTimeMethod · 0.65

Tested by

no test coverage detected