Skip to content

Commit d490841

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/upgrade-066
2 parents f0d1d64 + 0865756 commit d490841

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const (
44
DatabendTenantHeader = "X-DATABEND-TENANT"
55
DatabendWarehouseHeader = "X-DATABEND-WAREHOUSE"
66
DatabendQueryIDHeader = "X-DATABEND-QUERY-ID"
7+
DatabendQueryIDNode = "X-DATABEND-NODE-ID"
78
Authorization = "Authorization"
89
WarehouseRoute = "X-DATABEND-ROUTE"
910
UserAgent = "User-Agent"

query.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type DataField struct {
3030

3131
type QueryResponse struct {
3232
ID string `json:"id"`
33+
NodeID string `json:"node_id"`
3334
Session *json.RawMessage `json:"session"`
3435
Schema *[]DataField `json:"schema"`
3536
Data [][]string `json:"data"`

restful.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (c *APIClient) NewDefaultCopyOptions() map[string]string {
8080
type APIClient struct {
8181
SessionID string
8282
QuerySeq int64
83+
NodeID string
8384
cli *http.Client
8485
rows *nextRows
8586

@@ -219,6 +220,9 @@ func (c *APIClient) doRequest(ctx context.Context, method, path string, req inte
219220
if err != nil {
220221
return errors.Wrap(err, "failed to make request headers")
221222
}
223+
if method == "GET" && len(c.NodeID) != 0 {
224+
headers.Set(DatabendQueryIDNode, c.NodeID)
225+
}
222226
headers.Set(contentType, jsonContentType)
223227
headers.Set(accept, jsonContentType)
224228
httpReq.Header = headers
@@ -466,6 +470,7 @@ func (c *APIClient) startQueryRequest(ctx context.Context, request *QueryRequest
466470
// try update session as long as resp is not nil, even if query failed (resp.Error != nil)
467471
// e.g. transaction state need to be updated if commit fail
468472
c.applySessionState(&resp)
473+
c.NodeID = resp.NodeID
469474
c.trackStats(&resp)
470475
return &resp, nil
471476
}

0 commit comments

Comments
 (0)