MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / reverseTransform

Function reverseTransform

plugins/destination/sqlite/client/read.go:43–149  ·  view source on GitHub ↗
(sc *arrow.Schema, values []any)

Source from the content-addressed store, hash-verified

41}
42
43func reverseTransform(sc *arrow.Schema, values []any) (arrow.RecordBatch, error) {
44 bldr := array.NewRecordBuilder(memory.DefaultAllocator, sc)
45 for i, val := range values {
46 switch sc.Field(i).Type.ID() {
47 case arrow.BOOL:
48 if val.(*sql.NullBool).Valid {
49 bldr.Field(i).(*array.BooleanBuilder).Append(val.(*sql.NullBool).Bool)
50 } else {
51 bldr.Field(i).(*array.BooleanBuilder).AppendNull()
52 }
53 case arrow.INT8:
54 v := val.(*sql.NullInt64)
55 if !v.Valid {
56 bldr.Field(i).AppendNull()
57 } else {
58 bldr.Field(i).(*array.Int8Builder).Append(int8(v.Int64))
59 }
60 case arrow.INT16:
61 v := val.(*sql.NullInt64)
62 if !v.Valid {
63 bldr.Field(i).AppendNull()
64 } else {
65 bldr.Field(i).(*array.Int16Builder).Append(int16(v.Int64))
66 }
67 case arrow.INT32:
68 v := val.(*sql.NullInt64)
69 if !v.Valid {
70 bldr.Field(i).AppendNull()
71 } else {
72 bldr.Field(i).(*array.Int32Builder).Append(int32(v.Int64))
73 }
74 case arrow.INT64:
75 v := val.(*sql.NullInt64)
76 if !v.Valid {
77 bldr.Field(i).AppendNull()
78 } else {
79 bldr.Field(i).(*array.Int64Builder).Append(v.Int64)
80 }
81 case arrow.UINT8:
82 v := val.(*sql.NullInt64)
83 if !v.Valid {
84 bldr.Field(i).AppendNull()
85 } else {
86 bldr.Field(i).(*array.Uint8Builder).Append(uint8(v.Int64))
87 }
88 case arrow.UINT16:
89 v := val.(*sql.NullInt64)
90 if !v.Valid {
91 bldr.Field(i).AppendNull()
92 } else {
93 bldr.Field(i).(*array.Uint16Builder).Append(uint16(v.Int64))
94 }
95 case arrow.UINT32:
96 v := val.(*sql.NullInt64)
97 if !v.Valid {
98 bldr.Field(i).AppendNull()
99 } else {
100 bldr.Field(i).(*array.Uint32Builder).Append(uint32(v.Int64))

Callers 1

ReadMethod · 0.70

Calls 4

AppendMethod · 0.80
ErrorfMethod · 0.80
IDMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected