@@ -48,7 +48,6 @@ import (
4848type session struct {
4949 onClose []func (s * session )
5050 id string
51- cc grpc.ClientConnInterface
5251 tableService Ydb_Table_V1.TableServiceClient
5352 status table.SessionStatus
5453 config * config.Config
@@ -151,7 +150,6 @@ func newSession(ctx context.Context, cc grpc.ClientConnInterface, config *config
151150 id : result .GetSessionId (),
152151 config : config ,
153152 status : table .SessionReady ,
154- cc : cc ,
155153 }
156154 s .lastUsage .Store (time .Now ().Unix ())
157155
@@ -1253,32 +1251,47 @@ func (s *session) StreamExecuteScanQuery(
12531251 )
12541252}
12551253
1256- type bulkUpsertOptionToTableOption struct {
1257- opt []options.BulkUpsertOption
1258- }
1259-
1260- func (opt bulkUpsertOptionToTableOption ) ApplyTableOption (tableOpts * options.TableOptions ) {
1261- var callOpts []grpc.CallOption
1262- for _ , o := range opt .opt {
1263- callOpts = append (callOpts , o .ApplyBulkUpsertOption ()... )
1264- }
1265- tableOpts .CallOptions = append (tableOpts .CallOptions , callOpts ... )
1266- }
1267-
12681254// BulkUpsert uploads given list of ydb struct values to the table.
1269- func (s * session ) BulkUpsert (ctx context.Context , tableName string , rows value.Value ,
1255+ func (s * session ) BulkUpsert (ctx context.Context , table string , rows value.Value ,
12701256 opts ... options.BulkUpsertOption ,
12711257) (err error ) {
1272- client := New (ctx , s .cc , config .New ())
1258+ var (
1259+ a = allocator .New ()
1260+ callOptions []grpc.CallOption
1261+ onDone = trace .TableOnSessionBulkUpsert (
1262+ s .config .Trace (), & ctx ,
1263+ stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).BulkUpsert" ),
1264+ )
1265+ )
1266+ defer func () {
1267+ defer a .Free ()
1268+ onDone (err , 1 )
1269+ }()
1270+
1271+ for _ , opt := range opts {
1272+ if opt != nil {
1273+ callOptions = append (callOptions , opt .ApplyBulkUpsertOption ()... )
1274+ }
1275+ }
12731276
1274- return client .BulkUpsert (
1275- ctx ,
1276- tableName ,
1277- table.BulkUpsertRows {
1278- Rows : rows ,
1277+ _ , err = s .tableService .BulkUpsert (ctx ,
1278+ & Ydb_Table.BulkUpsertRequest {
1279+ Table : table ,
1280+ Rows : value .ToYDB (rows , a ),
1281+ OperationParams : operation .Params (
1282+ ctx ,
1283+ s .config .OperationTimeout (),
1284+ s .config .OperationCancelAfter (),
1285+ operation .ModeSync ,
1286+ ),
12791287 },
1280- bulkUpsertOptionToTableOption { opts } ,
1288+ callOptions ... ,
12811289 )
1290+ if err != nil {
1291+ return xerrors .WithStackTrace (err )
1292+ }
1293+
1294+ return nil
12821295}
12831296
12841297// BeginTransaction begins new transaction within given session with given settings.
0 commit comments