github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/tests/integration/table_bulk_upsert_with_compression_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package integration 5 6 import ( 7 "context" 8 "fmt" 9 "testing" 10 11 "google.golang.org/grpc" 12 "google.golang.org/grpc/encoding/gzip" 13 14 "github.com/ydb-platform/ydb-go-sdk/v3/table" 15 "github.com/ydb-platform/ydb-go-sdk/v3/table/options" 16 "github.com/ydb-platform/ydb-go-sdk/v3/table/types" 17 ) 18 19 func TestTableBulkUpsertWithCompression(t *testing.T) { 20 scope := newScope(t) 21 driver := scope.Driver() 22 tablePath := scope.TablePath() 23 24 // upsert 25 var rows []types.Value 26 27 for i := int64(0); i < 10; i++ { 28 val := fmt.Sprintf("value for %v", i) 29 rows = append(rows, types.StructValue( 30 types.StructFieldValue("id", types.Int64Value(i)), 31 types.StructFieldValue("val", types.TextValue(val)), 32 )) 33 } 34 35 err := driver.Table().Do(scope.Ctx, func(ctx context.Context, s table.Session) error { 36 return s.BulkUpsert(ctx, tablePath, types.ListValue(rows...), options.WithCallOptions( 37 grpc.UseCompressor(gzip.Name), 38 )) 39 }) 40 scope.Require.NoError(err) 41 }