(ctx context.Context, table *schema.Table, res chan<- arrow.RecordBatch)
| 10 | ) |
| 11 | |
| 12 | func (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 | |
| 40 | func wrap(arr []any) []any { |
| 41 | res := make([]any, len(arr)) |
nothing calls this directly
no test coverage detected