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

Method Read

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

Source from the content-addressed store, hash-verified

224}
225
226func (c *Client) Read(ctx context.Context, table *schema.Table, res chan<- arrow.RecordBatch) error {
227 colNames := make([]string, len(table.Columns))
228 for i, col := range table.Columns {
229 colNames[i] = identifier(col.Name)
230 }
231 cols := strings.Join(colNames, ", ")
232 read := fmt.Sprintf(readSQL, cols, table.Name)
233 rows, err := c.db.QueryContext(ctx, read)
234 if err != nil {
235 return err
236 }
237 defer rows.Close()
238 arrowSchemaTable := table.ToArrowSchema()
239 for rows.Next() {
240 values := c.createResultsArray(arrowSchemaTable)
241 if err := rows.Scan(values...); err != nil {
242 return fmt.Errorf("failed to read from table %s: %w", table.Name, err)
243 }
244 record, err := reverseTransform(arrowSchemaTable, values)
245 if err != nil {
246 return err
247 }
248 res <- record
249 }
250 return nil
251}

Callers

nothing calls this directly

Calls 7

createResultsArrayMethod · 0.95
NextMethod · 0.80
ScanMethod · 0.80
ErrorfMethod · 0.80
identifierFunction · 0.70
reverseTransformFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected