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

Method Read

plugins/destination/mssql/client/read.go:12–38  ·  view source on GitHub ↗
(ctx context.Context, table *schema.Table, res chan<- arrow.RecordBatch)

Source from the content-addressed store, hash-verified

10)
11
12func (c *Client) Read(ctx context.Context, table *schema.Table, res chan<- arrow.RecordBatch) error {
13 query := queries.Read(c.spec.Schema, table)
14 sc := table.ToArrowSchema()
15
16 return c.doInTx(ctx, func(tx *sql.Tx) error {
17 rows, err := tx.QueryContext(ctx, query)
18 if err != nil {
19 return err
20 }
21
22 return processRows(rows, func(row *sql.Rows) error {
23 // We consider only the current schema from table
24 resource := make([]any, len(sc.Fields()))
25 if err := row.Scan(wrap(resource)...); err != nil {
26 return err
27 }
28
29 record, err := queries.Record(sc, resource)
30 if err != nil {
31 return err
32 }
33
34 res <- record
35 return nil
36 })
37 })
38}
39
40func wrap(arr []any) []any {
41 res := make([]any, len(arr))

Callers

nothing calls this directly

Calls 4

doInTxMethod · 0.95
processRowsFunction · 0.85
wrapFunction · 0.85
ScanMethod · 0.80

Tested by

no test coverage detected