(ctx context.Context, msgs <-chan *message.WriteInsert)
| 49 | } |
| 50 | |
| 51 | func (c *Client) WriteTable(ctx context.Context, msgs <-chan *message.WriteInsert) error { |
| 52 | var s *filetypes.Stream |
| 53 | |
| 54 | for msg := range msgs { |
| 55 | if s == nil { |
| 56 | table := msg.GetTable() |
| 57 | objKey := c.spec.ReplacePathVariables(table.Name, uuid.NewString(), time.Now().UTC(), c.syncID) |
| 58 | // if object was already initialized, use the same key |
| 59 | c.initializedTablesLock.Lock() |
| 60 | if val, ok := c.initializedTables[table.Name]; ok { |
| 61 | objKey = val |
| 62 | delete(c.initializedTables, table.Name) |
| 63 | } |
| 64 | c.initializedTablesLock.Unlock() |
| 65 | |
| 66 | var err error |
| 67 | s, err = c.createObject(ctx, table, objKey) |
| 68 | if err != nil { |
| 69 | return err |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | if c.spec.Athena { |
| 74 | var err error |
| 75 | msg.Record, err = sanitizeRecordJSONKeys(msg.Record) |
| 76 | if err != nil { |
| 77 | _ = s.FinishWithError(err) |
| 78 | return err |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if err := s.Write([]arrow.RecordBatch{msg.Record}); err != nil { |
| 83 | _ = s.FinishWithError(err) |
| 84 | return err |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | return s.Finish() |
| 89 | } |
| 90 | |
| 91 | func (c *Client) Write(ctx context.Context, msgs <-chan message.WriteMessage) error { |
| 92 | return c.writer.Write(ctx, msgs) |
nothing calls this directly
no test coverage detected