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

Method WriteTable

plugins/destination/s3/client/write.go:51–89  ·  view source on GitHub ↗
(ctx context.Context, msgs <-chan *message.WriteInsert)

Source from the content-addressed store, hash-verified

49}
50
51func (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
91func (c *Client) Write(ctx context.Context, msgs <-chan message.WriteMessage) error {
92 return c.writer.Write(ctx, msgs)

Callers

nothing calls this directly

Calls 5

createObjectMethod · 0.95
WriteMethod · 0.95
sanitizeRecordJSONKeysFunction · 0.85
FinishMethod · 0.65
ReplacePathVariablesMethod · 0.45

Tested by

no test coverage detected