Skip to content

Commit 09b2a4d

Browse files
authored
fix: query response data should be [][]string (#39)
1 parent c95b6b4 commit 09b2a4d

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

con_batch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func (dc *DatabendConn) prepareBatch(ctx context.Context, query string) (ldriver
4646
var columnNames, columnTypes []string
4747
for i := range r.Data {
4848
if len(r.Data[i]) > 1 {
49-
columnNames = append(columnNames, fmt.Sprintf("%s", r.Data[i][0]))
50-
columnTypes = append(columnTypes, fmt.Sprintf("%s", r.Data[i][1]))
49+
columnNames = append(columnNames, r.Data[i][0])
50+
columnTypes = append(columnTypes, r.Data[i][1])
5151
}
5252
}
5353

query.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ type DataField struct {
2525
}
2626

2727
type QueryResponse struct {
28-
Data [][]interface{} `json:"data"`
29-
Error *QueryError `json:"error"`
30-
FinalURI string `json:"final_uri"`
31-
Id string `json:"id"`
32-
NextURI string `json:"next_uri"`
33-
Schema []DataField `json:"schema"`
34-
State string `json:"state"`
35-
Stats QueryStats `json:"stats"`
36-
StatsURI string `json:"stats_uri"`
28+
Data [][]string `json:"data"`
29+
Error *QueryError `json:"error"`
30+
FinalURI string `json:"final_uri"`
31+
Id string `json:"id"`
32+
NextURI string `json:"next_uri"`
33+
Schema []DataField `json:"schema"`
34+
State string `json:"state"`
35+
Stats QueryStats `json:"stats"`
36+
StatsURI string `json:"stats_uri"`
3737
}
3838

3939
type QueryStats struct {

restful.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,10 @@ func (c *APIClient) UploadToStageByPresignURL(stage, fileName string) error {
249249
if len(resp.Data) < 1 || len(resp.Data[0]) < 2 {
250250
return fmt.Errorf("generate presign url failed")
251251
}
252-
headers, ok := resp.Data[0][1].(map[string]interface{})
253-
if !ok {
254-
return fmt.Errorf("no host for presign url")
252+
headers := make(map[string]string)
253+
err = json.Unmarshal([]byte(resp.Data[0][1]), &headers)
254+
if err != nil {
255+
return errors.Wrap(err, "failed to unmarshal presign url headers")
255256
}
256257

257258
presignURL := fmt.Sprintf("%v", resp.Data[0][2])

rows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (r *nextRows) Next(dest []driver.Value) error {
105105
r.respData.Data = r.respData.Data[1:]
106106

107107
for j := range lineData {
108-
reader := strings.NewReader(fmt.Sprintf("%v", lineData[j]))
108+
reader := strings.NewReader(lineData[j])
109109
v, err := r.parsers[j].Parse(reader)
110110
if err != nil {
111111
r.dc.log("parse error ", err)

rows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestTextRows(t *testing.T) {
1111
rows, err := newNextRows(&DatabendConn{}, &QueryResponse{
12-
Data: [][]interface{}{{1, 2, "3"}, {3, 2, "1"}},
12+
Data: [][]string{{"1", "2", "3"}, {"3", "2", "1"}},
1313
Schema: []DataField{
1414
{Name: "age", Type: "Int32"},
1515
{Name: "height", Type: "Int64"},

0 commit comments

Comments
 (0)