Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/upgrade-066
Browse files Browse the repository at this point in the history
  • Loading branch information
hantmac committed Jun 13, 2024
2 parents f0d1d64 + 0865756 commit d490841
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const (
DatabendTenantHeader = "X-DATABEND-TENANT"
DatabendWarehouseHeader = "X-DATABEND-WAREHOUSE"
DatabendQueryIDHeader = "X-DATABEND-QUERY-ID"
DatabendQueryIDNode = "X-DATABEND-NODE-ID"
Authorization = "Authorization"
WarehouseRoute = "X-DATABEND-ROUTE"
UserAgent = "User-Agent"
Expand Down
1 change: 1 addition & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type DataField struct {

type QueryResponse struct {
ID string `json:"id"`
NodeID string `json:"node_id"`
Session *json.RawMessage `json:"session"`
Schema *[]DataField `json:"schema"`
Data [][]string `json:"data"`
Expand Down
5 changes: 5 additions & 0 deletions restful.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (c *APIClient) NewDefaultCopyOptions() map[string]string {
type APIClient struct {
SessionID string
QuerySeq int64
NodeID string
cli *http.Client
rows *nextRows

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

0 comments on commit d490841

Please sign in to comment.