@@ -5,16 +5,13 @@ import (
55 "sync/atomic"
66 "time"
77
8- "github.com/ydb-platform/ydb-go-genproto/Ydb_Operation_V1"
98 "github.com/ydb-platform/ydb-go-genproto/Ydb_Query_V1"
10- "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
119 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Operations"
1210 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Query"
1311 "google.golang.org/grpc"
1412
1513 "github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1614 "github.com/ydb-platform/ydb-go-sdk/v3/internal/closer"
17- "github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
1815 "github.com/ydb-platform/ydb-go-sdk/v3/internal/operation"
1916 "github.com/ydb-platform/ydb-go-sdk/v3/internal/pool"
2017 "github.com/ydb-platform/ydb-go-sdk/v3/internal/query/config"
@@ -49,37 +46,14 @@ type (
4946 InUse atomic.Int32
5047 }
5148 Client struct {
52- config * config.Config
53- queryServiceClient Ydb_Query_V1.QueryServiceClient
54- operationServiceClient Ydb_Operation_V1.OperationServiceClient
55- pool sessionPool
49+ config * config.Config
50+ queryServiceClient Ydb_Query_V1.QueryServiceClient
51+ pool sessionPool
5652
5753 done chan struct {}
5854 }
5955)
6056
61- func fetchScriptResultsWithFallback (ctx context.Context ,
62- queryServiceClient Ydb_Query_V1.QueryServiceClient ,
63- operationServiceClient Ydb_Operation_V1.OperationServiceClient ,
64- opID string , opts ... options.FetchScriptOption ,
65- ) (* options.FetchScriptResult , error ) {
66- r , err := fetchScriptResults (ctx , queryServiceClient , opID , opts ... )
67- if err != nil {
68- if xerrors .IsOperationError (err , Ydb .StatusIds_BAD_REQUEST ) {
69- r , err = scriptOperationStatus (ctx , operationServiceClient , opID )
70- if err != nil {
71- return nil , xerrors .WithStackTrace (err )
72- }
73-
74- return r , nil
75- }
76-
77- return nil , xerrors .WithStackTrace (err )
78- }
79-
80- return r , nil
81- }
82-
8357func fetchScriptResults (ctx context.Context ,
8458 client Ydb_Query_V1.QueryServiceClient ,
8559 opID string , opts ... options.FetchScriptOption ,
@@ -115,13 +89,9 @@ func fetchScriptResults(ctx context.Context,
11589 }
11690
11791 return & options.FetchScriptResult {
118- Ready : true ,
119- Status : response .GetStatus ().String (),
120- Data : & options.FetchScriptResultData {
121- ResultSetIndex : response .GetResultSetIndex (),
122- ResultSet : MaterializedResultSet (int (response .GetResultSetIndex ()), columnNames , columnTypes , rows ),
123- NextToken : response .GetNextFetchToken (),
124- },
92+ ResultSetIndex : response .GetResultSetIndex (),
93+ ResultSet : MaterializedResultSet (int (response .GetResultSetIndex ()), columnNames , columnTypes , rows ),
94+ NextToken : response .GetNextFetchToken (),
12595 }, nil
12696 }, retry .WithIdempotent (true ))
12797 if err != nil {
@@ -131,40 +101,11 @@ func fetchScriptResults(ctx context.Context,
131101 return r , nil
132102}
133103
134- func scriptOperationStatus (
135- ctx context.Context , client Ydb_Operation_V1.OperationServiceClient , opID string ,
136- ) (* options.FetchScriptResult , error ) {
137- status , err := retry .RetryWithResult (ctx , func (ctx context.Context ) (* options.FetchScriptResult , error ) {
138- response , err := client .GetOperation (conn .WithoutWrapping (ctx ), & Ydb_Operations.GetOperationRequest {
139- Id : opID ,
140- })
141- if err != nil {
142- return nil , xerrors .WithStackTrace (err )
143- }
144-
145- var md Ydb_Query.ExecuteScriptMetadata
146- err = response .GetOperation ().GetMetadata ().UnmarshalTo (& md )
147- if err != nil {
148- return nil , xerrors .WithStackTrace (err )
149- }
150-
151- return & options.FetchScriptResult {
152- Ready : response .GetOperation ().GetReady (),
153- Status : response .GetOperation ().GetStatus ().String (),
154- }, nil
155- })
156- if err != nil {
157- return nil , xerrors .WithStackTrace (err )
158- }
159-
160- return status , nil
161- }
162-
163104func (c * Client ) FetchScriptResults (ctx context.Context ,
164105 opID string , opts ... options.FetchScriptOption ,
165106) (* options.FetchScriptResult , error ) {
166107 r , err := retry .RetryWithResult (ctx , func (ctx context.Context ) (* options.FetchScriptResult , error ) {
167- r , err := fetchScriptResultsWithFallback (ctx , c .queryServiceClient , c . operationServiceClient , opID ,
108+ r , err := fetchScriptResults (ctx , c .queryServiceClient , opID ,
168109 append (opts , func (request * options.FetchScriptResultsRequest ) {
169110 request .Trace = c .config .Trace ()
170111 })... ,
@@ -688,10 +629,9 @@ func New(ctx context.Context, balancer grpc.ClientConnInterface, cfg *config.Con
688629 grpcClient := Ydb_Query_V1 .NewQueryServiceClient (balancer )
689630
690631 client := & Client {
691- config : cfg ,
692- queryServiceClient : grpcClient ,
693- operationServiceClient : Ydb_Operation_V1 .NewOperationServiceClient (balancer ),
694- done : make (chan struct {}),
632+ config : cfg ,
633+ queryServiceClient : grpcClient ,
634+ done : make (chan struct {}),
695635 pool : newPool (ctx , cfg , func (ctx context.Context ) (_ * Session , err error ) {
696636 var (
697637 createCtx context.Context
0 commit comments