@@ -6,21 +6,21 @@ import (
66
77 "github.com/apache/arrow/go/v13/arrow"
88 "github.com/cloudquery/plugin-pb-go/specs"
9- "github.com/cloudquery/plugin-sdk/v2 /schema"
9+ "github.com/cloudquery/plugin-sdk/v3 /schema"
1010)
1111
12- func (c * Client ) WriteTableBatch (ctx context.Context , sc * arrow. Schema , records []arrow.Record ) error {
13- index , err := c .Meilisearch .GetIndex (schema . TableName ( sc ) )
12+ func (c * Client ) WriteTableBatch (ctx context.Context , table * schema. Table , records []arrow.Record ) error {
13+ index , err := c .Meilisearch .GetIndex (table . Name )
1414 if err != nil {
1515 return err
1616 }
1717
1818 var transformer rowTransformer
1919 switch c .dstSpec .WriteMode {
2020 case specs .WriteModeAppend :
21- transformer = toMap (sc )
21+ transformer = toMap (table )
2222 case specs .WriteModeOverwrite , specs .WriteModeOverwriteDeleteStale :
23- transformer = toMapWithHash (sc )
23+ transformer = toMapWithHash (table )
2424 default :
2525 return fmt .Errorf ("unsupported write mode %q" , c .dstSpec .WriteMode .String ())
2626 }
@@ -48,11 +48,8 @@ func (c *Client) WriteTableBatch(ctx context.Context, sc *arrow.Schema, records
4848
4949type rowTransformer func (record arrow.Record ) ([]map [string ]any , error )
5050
51- func toMap (sc * arrow.Schema ) rowTransformer {
52- columns := make ([]string , len (sc .Fields ()))
53- for i , fld := range sc .Fields () {
54- columns [i ] = fld .Name
55- }
51+ func toMap (table * schema.Table ) rowTransformer {
52+ columns := table .Columns .Names ()
5653 return func (record arrow.Record ) ([]map [string ]any , error ) {
5754 byColumn := make (map [string ][]any , len (columns ))
5855 for i , col := range record .Columns () {
@@ -62,9 +59,9 @@ func toMap(sc *arrow.Schema) rowTransformer {
6259 }
6360}
6461
65- func toMapWithHash (sc * arrow. Schema ) rowTransformer {
66- m := toMap (sc )
67- h := hashUUID (sc )
62+ func toMapWithHash (table * schema. Table ) rowTransformer {
63+ m := toMap (table )
64+ h := hashUUID (table )
6865 return func (record arrow.Record ) ([]map [string ]any , error ) {
6966 rows , err := m (record )
7067 if err != nil {
0 commit comments